I need to know how can I use app path? I have a added Shockwave Flash Object control there in my program. However I have added AxShockwaveFlash1(swfla1) there in my form.
I have written code there in Form_Load event so that swfla1 will get flash file(.swf) to play.

Form_Load event code : Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
swfla1.Movie = ("D:\Documents and Settings\James\My Documents\Test project\Animation\Animation.swf")
End Sub

Swfla1 will get flash file (.swf) from ("D:\Documents and Settings\James\My Documents\Test project\Animation\Animation.swf") this location. As a result if user will install it there in another drive it will show error message or it will not work. So I want to know how can I use app path so solve this problem? Please help me.

Environment.GetFolderPath() -function gives you the correct path. Function parameter is one of the Environment.SpecialFolder -enumeration values.

Dim PathStr As String

    PathStr = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
    ' Append "\" if missing
    If PathStr.Length > 0 AndAlso Not PathStr.EndsWith(Path.DirectorySeparatorChar) Then
      PathStr &= Path.DirectorySeparatorChar
    End If
    ' Append hard-coded subfolder and file name (or read it from a file, prompt user, or...)
    PathStr &= "Test project\Animation\Animation.swf"

The code above should give you:

PathStr = "D:\Documents and Settings\James\My Documents\Test project\Animation\Animation.swf"

and if you had Windows Vista/7 you should get:

PathStr = "C:\Users\James\My Documents\Test project\Animation\Animation.swf"

The point is to use Environment.GetFolderPath() -function, not to hard-code special folder names since they are different between Windows versions.

HTH

Hi,

Or you can use the application StartupPath.

'First , add reference to ShockWave Flash Object Library
'existed on the COM Tab . Paste the control on your form.
'Use the code below as follow : 
'Add your flashfile to the Bin folder

Public Class Form1
    Inherits System.Windows.Forms.Form

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        With FlashObj
            .Stop()
            .Movie = Application.StartupPath & "\nameofyourflashfile.swf"
            .Play()
        End With
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        FlashObj.Dispose()
        Application.Exit()
    End Sub


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class

you can get the path by using this

Application.StartupPath & "Animation.swf"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.