Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27350

VS 2005 [RESOLVED] Application.StartupPath Not Showing File

$
0
0
Code:

Private Sub ManipulateFile()
                'First File Path
        'Dim filepath As String = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) & "\Hello.txt"

        'Second File Path
        Dim filepath As String = Application.StartupPath & "\Hello.txt"

        Dim fs As FileStream = Nothing

        Try
            fs = New FileStream(filepath, FileMode.Create, FileAccess.Write, FileShare.None)
            fs.Close()
        Catch ex As Exception
        End Try

        Try
            Dim sw As StreamWriter = Nothing
            sw = New StreamWriter(filepath)
            sw.WriteLine("Hello World")
            sw.Flush()
            sw.Close()
        Catch ex As Exception

        End Try
    End Sub

I am not understanding one thing in the above code that if I use First File Path, the file is created in the Application.StartupPath but it does
show the file in debug folder or release folder when I run from inside visual studio ide but if I create a setup and run the exe, the file is not found
inside the application folder. But if I use the second file path everything is OK, the file can be found in the desktop.

Please help me understand this issue.

Viewing all articles
Browse latest Browse all 27350

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>