Solved

StreamWriter

Posted on 2014-03-12
3
178 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
Comment Utility
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
 

Author Comment

by:Alyanto
Comment Utility
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
 

Author Closing Comment

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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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.
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 explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

6 Experts available now in Live!

Get 1:1 Help Now