Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple write to file with smart device...

Status
Not open for further replies.

Programmer76

Programmer
Jul 25, 2006
35
CA
Hi,

I am learing smart device programming and can't seem to do a simple open and create a file...

Code:
        Dim fs As FileStream = File.Open(System.IO.Directory.GetCurrentDirectory + Me.sFileName, FileMode.Create, FileAccess.Write)
        Dim sw As New StreamWriter(fs)

        'Serialize the arraylist to a text file
        For Each t As Task In Me.alTask
            sw.WriteLine(t.Serialize())
        Next

        sw.Flush()
        sw.Close()

        fs.Close()

I get an error stateing that GetCurrentDirectory is not supported...can someone tell me what I should be using?

 
What should GetCurrentDirectory point to?

If its the applications folder then you should use:
Code:
Application.StartupPath() & "\FileName"
 
Have you tried changing the + operator to the & operator? Also, when I do this sort of thing I tend to use () as well such as :

File.Open((System.IO.Directory.GetCurrentDirectory() & Me.sFileName()), FileMode.Create, FileAccess.Write)

HTH
 
What i was tring to ask, what did you want GetCurrentDirectory() to point to?

If its the apps directory then you'll need to use Application.StartupPath()

The GetCurrentDirectory() could point anywhere at any time, if you open a folder browser window or a cmd window and change the pointing directory (cd ...) it will change this path as well. because of this i think that winxp and latter, have removed the CurrentDirectory api.

The "&" is just good vb programming, because "+" is used for math functions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top