Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 188
  • Last Modified:

StreamWriter

I am scratching this bit of code together and running into a little unusual behavior.  Irrespective of the path I assign to the file it seems to be placing it in.

C:\Users\symingtonc\Documents\Visual Studio 2008\Projects\PIAuditorware\PIAuditorware\bin\Debug\C\ScannerExport

Can explain why this might be and a remedy, I am not receiving an error message at any point.



  Public Function ExportFile() As Boolean
        Dim TempPath As String = "C\ScannerExport\"
        TempPath = My.Computer.FileSystem.SpecialDirectories.MyDocuments

        If Not Directory.Exists(TempPath) Then
            Directory.CreateDirectory(TempPath)
        End If

        TempPath &= "\export.txt"
        If File.Exists(TempPath) Then File.Delete(TempPath)

        If File.Exists("C\ScannerExport\export.txt") Then File.Delete("C\ScannerExport\export.txt")
        Using WriteTo As StreamWriter = New StreamWriter(File.Open("C\ScannerExport\export.txt", FileMode.CreateNew))
            For Each stkItem As XMLStock In StockList
                Dim NewLine As String = String.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}|{7}", BranchNumber, Now.ToShortDateString, stkItem.LongCode, stkItem.ShortCode, stkItem.ProductDescription, stkItem.CurrentStockUnits, IIf(stkItem.Specific, "TRUE", "FALSE"), IIf(stkItem.MarkedDown, "TRUE", "FALSE"))
                WriteTo.WriteLine(NewLine)
            Next
        End Using
    End Function

Open in new window

0
Alyanto
Asked:
Alyanto
  • 2
1 Solution
 
Ess KayEntrapenuerCommented:
delete line 3 :


TempPath = My.Computer.FileSystem.SpecialDirectories.MyDocuments



also, if you want C drive and not C folder


you need to add the colon

c:/

not c/
0
 
AlyantoAuthor Commented:
I was about to edit that out from the question because it is actually a bit misleading.  The paths are entered in lines 12 and 13.    

I wanted to experiment with the path which is why it is done that way.  Line 3 is where I would really like to place the files.
0
 
AlyantoAuthor Commented:
C:\ was the trick.  Maybe I need to take a break.  Many thanks Aly
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now