• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2288
  • Last Modified:

File or Directory does not exist

Hi,

I am using the below code snippet to create directory and file within directory...

But at some point i am getting Error: Error #3003: File or directory does not exist.
 Can upls let me know whats wrong...

   
var prepStoragePath:File = File.applicationStorageDirectory.resolvePath("My Documents/Preparations");
				var userPrepFileStoragePath:File = prepStoragePath.resolvePath(event.clientName + event.caseType);
				userPrepFileStoragePath.createDirectory();
				var userDocument:String = userDoc.htmlText;
				var prepFilePath:File = userPrepFileStoragePath.resolvePath(event.fileName+".html");
				var fileStream:FileStream = new FileStream();
				fileStream.open(prepFilePath, FileMode.WRITE);
				fileStream.writeUTFBytes(userDocument);
				fileStream.close();

Open in new window


0
SreeramojuPradeep
Asked:
SreeramojuPradeep
  • 2
  • 2
1 Solution
 
deepanjandasCommented:
trace userPrepFileStoragePath.nativePath and see what it returns.
It seems the path is invalid.

Warm Regards
Deepanjan Das
0
 
dgofmanCommented:
This code should always work for you if you are using AIR not Flash Player :)

var prepStoragePath:File = File.applicationStorageDirectory.resolvePath("My Documents");
if(!prepStoragePath.exists)
      prepStoragePath.createDirectory();
prepStoragePath = prepStoragePath.resolvePath("Preparations");
if(!prepStoragePath.exists)
      prepStoragePath.createDirectory();

var userPrepFileStoragePath:File = prepStoragePath.resolvePath(event.clientName + event.caseType);
userPrepFileStoragePath.createDirectory();
var userDocument:String = userDoc.htmlText;
var prepFilePath:File = userPrepFileStoragePath.resolvePath(event.fileName+".html");
var fileStream:FileStream = new FileStream();
fileStream.open(prepFilePath, FileMode.WRITE);
fileStream.writeUTFBytes(userDocument);
fileStream.close();

fileStream = new FileStream();
fileStream.open(prepFilePath, FileMode.READ);
var txt:String = fileStream.readUTFBytes(fileStream.bytesAvailable);
fileStream.close();
Alert.show(txt, "read from file");
0
 
SreeramojuPradeepAuthor Commented:
Then can u let me know how to resolve the complete path...

I have already created all the directories at the app start up in the same fashion u have given.... so how to resolve complete path  ".lawPadHiddenDir/My Documents/Preparations"

var prepStoragePath:File = File.applicationStorageDirectory.resolvePath(".lawPadHiddenDir/My Documents/Preparations");
0
 
SreeramojuPradeepAuthor Commented:
Can u pls let me know how to resolve the complete path once the directories is already created...
0
 
dgofmanCommented:
What do you mean?
trace(prepStoragePath:File .nativePath) will show full path to your existing directory
Please read Adobe documentation how to work with File class

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/File.html
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now