Solved

StreamWriter

Posted on 2014-03-12
3
182 Views
Last Modified: 2014-03-12
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
Comment
Question by:Alyanto
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
Ess Kay earned 500 total points
ID: 39923970
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
 
LVL 1

Author Comment

by:Alyanto
ID: 39924000
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
 
LVL 1

Author Closing Comment

by:Alyanto
ID: 39924075
C:\ was the trick.  Maybe I need to take a break.  Many thanks Aly
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now