x


File.Create not working

I used a Serializer script for a save system, but when I use a path that doesn't have the save file inside, it doesn't work. It says that it cannot find the file.

Stream stream = File.Open(Application.persistentDataPath + "/" + filePath, FileMode.Create);

FileMode.Create seems not to work, in creating a new file. I also used File.Exists to check if the file exists, and if not I used File.Create, but it did not work.

Update: It show me an error when I try to access an empty or missing file.

more ▼

asked May 17 '12 at 11:00 PM

simeonradivoev gravatar image

simeonradivoev
37 6 8 9

It says that it cannot find the file.

What exact error message are you seeing?

For that matter, which platform are you on?

when I use a path that doesn't have the save file inside, it doesn't work

Not sure what you mean by this. You're using a path that doesn't include the name of the file you're trying to open, and still expect it to open the file? Perhaps I'm missing something.

May 18 '12 at 01:14 AM rutter

I was trying to Load the game data from the save file from the Start Function, so when the file was missing or empty, i got an error :X

So I used to check if the file exists (in javascript), and if it does then load the data. I don't know how to check if the file is empty.

'if (System.IO.File.Exists(SaveAndLoad.currentFilePath)){ localData = SaveAndLoad.Load(); }'

May 18 '12 at 01:17 AM simeonradivoev
(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x4171
x242
x141
x39

asked: May 17 '12 at 11:00 PM

Seen: 634 times

Last Updated: May 18 '12 at 01:31 AM