I have a vb.net project which i have inserted pictures and video.
I inserted a video clip using the Windows Media Player control and it does work. The issue i have is that i can't move the program to another computer because the pathname for the video will be wrong. I know i could change the pathname when i move it but this is not practical because i need to present this program. Does anybody know how to make the video accessible no matter what location the program is at?

Thanks

I have a vb.net project which i have inserted pictures and video.
I inserted a video clip using the Windows Media Player control and it does work. The issue i have is that i can't move the program to another computer because the pathname for the video will be wrong. I know i could change the pathname when i move it but this is not practical because i need to present this program. Does anybody know how to make the video accessible no matter what location the program is at?

Thanks

Hi,

Copy your video file to a folder within your app (right-click the project name in Solution Explorer and Add > New Folder then right-click the new folder and Add > Existing Item).

Once you have the file copied you can use the following (to get the file location):

Private applicationPath As String

Public Property AppPath() As String
        Get
            AppPath = applicationPath
        End Get
        Set(ByVal value As String)
            applicationPath = value
            If InStr(applicationPath, "bin\Debug", CompareMethod.Text) Then
                applicationPath = Microsoft.VisualBasic.Left(applicationPath, (InStr(applicationPath, "bin\Debug", CompareMethod.Text) - 1))
            End If
        End Set
    End Property

'In your form:
AppPath = System.Windows.Forms.Application.StartupPath 'I usually put this in the Load event of the first form to open
myVideo = AppPath & "\VideoFolderName\VideoName"

HTH,

Chris.

Thank for the reply
Iv added the video file to the folder

Which form do lines 1-13 go?
I tried using the code I am getting errors such as "Set is not supported anymore"

Hi,

Copy your video file to a folder within your app (right-click the project name in Solution Explorer and Add > New Folder then right-click the new folder and Add > Existing Item).

Once you have the file copied you can use the following (to get the file location):

Private applicationPath As String

Public Property AppPath() As String
        Get
            AppPath = applicationPath
        End Get
        Set(ByVal value As String)
            applicationPath = value
            If InStr(applicationPath, "bin\Debug", CompareMethod.Text) Then
                applicationPath = Microsoft.VisualBasic.Left(applicationPath, (InStr(applicationPath, "bin\Debug", CompareMethod.Text) - 1))
            End If
        End Set
    End Property

'In your form:
AppPath = System.Windows.Forms.Application.StartupPath 'I usually put this in the Load event of the first form to open
myVideo = AppPath & "\VideoFolderName\VideoName"

HTH,

Chris.

I apologise, i incorrectly put the code in.
I am having a problem with the last line of code that goes in the form load. myVideo is not declared. What do i declare it as?

Thank for the reply
Iv added the video file to the folder

Which form do lines 1-13 go?
I tried using the code I am getting errors such as "Set is not supported anymore"

I generally have all of my Properties in a Module but it's not crucial.

You don't need to have AppPath as a Property either - just set it as a variable in your Form:

Private AppPath As String

'In the Form Load Event
AppPath = System.Windows.Forms.Application.StartupPath
If InStr(AppPath, "bin\Debug", CompareMethod.Text) Then AppPath= Microsoft.VisualBasic.Left(AppPath, (InStr(AppPath, "bin\Debug", CompareMethod.Text) - 1))
myVideo = AppPath & "\VideoFolderName\VideoName"

Oops, we're getting our posts crossed here...

myVideo is just an example - all you need to do is replace the current file path of your video with AppPath & "\VideoFolderName\VideoName" where VideoFolderName is the name of your new Project Folder and VideoName is, well, the File Name (with extension) of your video.

Oops, we're getting our posts crossed here...

myVideo is just an example - all you need to do is replace the current file path of your video with AppPath & "\VideoFolderName\VideoName" where VideoFolderName is the name of your new Project Folder and VideoName is, well, the File Name (with extension) of your video.

Sorry im not very experienced in programming. I think iv put the code in the wrong place.
In the form load i have inserted this code and inserted the path of the video like you said. when i run it doesn't compile. It says myVideo is not declared? Sorry for all the questions

AppPath = System.Windows.Forms.Application.StartupPath
        If InStr(AppPath, "bin\Debug", CompareMethod.Text) Then AppPath = Microsoft.VisualBasic.Left(AppPath, (InStr(AppPath, "bin\Debug", CompareMethod.Text) - 1))
        myVideo = AppPath & "\Video\soundTest2.avi"
This article has been dead for over six months. Start a new discussion instead.