Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

StreamWriter

Posted on 2014-03-12
3
Medium Priority
?
187 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
Ess Kay earned 2000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

671 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