1 Replies - 594 Views - Last Post: 29 August 2013 - 04:51 PM Rate Topic: -----

#1 mattcash83  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 23-June 12

File.Create in Console Application

Posted 29 August 2013 - 04:41 PM

I am playing around with a console application using vb.net. I want the app to save the user's input during interaction to a text file and then read that text file the next time it loads. Pretty simple, done it a lot in Windows Forms applications with no issue. When I try

Dim _file as string = (System.IO.Directory.GetCurrentDirectory()& "\data.txt")

System.IO.File.Create(_file)
System.IO.File.WriteAllText(_file, "New User")

'Blah Blahh
'...........
'............
'............




I get an UnauthorizedAccessException, and when I go back and look at why, I find that the app has created a folder named "data.txt" instead of a text file. I cannot seam to figure out why. Is it because this is a console app? Any help is appreciated, thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: File.Create in Console Application

#2 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3219
  • View blog
  • Posts: 10,794
  • Joined: 12-December 12

Re: File.Create in Console Application

Posted 29 August 2013 - 04:51 PM

What is your current directory?

You can output it using:

Console.WriteLine(System.IO.Directory.GetCurrentDirectory())

This post has been edited by andrewsw: 29 August 2013 - 04:52 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1