• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Strange Error #2038: File I/O Error

Guest
Mar 24, 2013 Mar 24, 2013

Copy link to clipboard

Copied

Hi

I'm making a simple file renamer, for a bunch of mp3s in a folder.

The code in question is...

var _mySourceAudio:File = File.userDirectory.resolvePath( _sourceMinusExt + _extension );

var pathToNewFile:String = File.applicationDirectory.resolvePath (_location + _extension).nativePath;

var _myDestinationAudio:File = new File (pathToNewFile);

_mySourceAudio.moveTo(_myDestinationAudio, true);

if (_mySourceAudio.exists) trace ('yahoo');// always traces yahoo

Certain files in this folder refuse to change their name (there are no naming conflicts) and throw the 2038 error. Other files are renamed fine when I throw them at the function.

The above code always traces out that the file exists, so the path I'm injecting into it is fine

If I copy the misbehaving files to another folder, and do the edit, they rename fine. Copy this newly renamed file back over the old one in the orignal folder, and back to square one again.

I've spent most of the day debugging this - I'm just wondering if there is something less code related about files that I should be aware of that can cause this?

Cheers guys.

TOPICS
ActionScript

Views

5.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Mar 24, 2013 Mar 24, 2013

Copy link to clipboard

Copied

1.Under Windows there are certain hidden file in a lot of folders, you can`t obviously rename your files to one of those.

2.Try to deactivate your antivirus program for the folders for whichyou attempt renaming, some Protections won`t throw an explicit message when surpressing potential threats

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 25, 2013 Mar 25, 2013

Copy link to clipboard

Copied

trace() each step of that operation and give an example of a file/folder that's giving you an issue. Make sure you trace _sourceMinusExt + _extension, _location + _extension and your  _myDestinationAudio.nativePath. Paste an example path/file here.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 04, 2013 Apr 04, 2013

Copy link to clipboard

Copied

Thanks for taking a look guys.

Here's a successful edit (swapping the postions of the title and artist):

_sourceMinusExt + _extension: F:/songs backup/MM00016 - 3 DOORS DOWN - When I'm Gone.mp3

_location + _extension: F:/songs backup/MM00016 - When I'm Gone - 3 DOORS DOWN.mp3

_myDestinationAudio.nativePath: F:\songs backup\MM00016 - When I'm Gone - 3 DOORS DOWN.mp3

and one that throws the #2038: File I/O Error:

_sourceMinusExt + _extension: F:/songs backup/SPC0101 - 3 DOORS DOWN - Kryptonite.mp3

_location + _extension: F:/songs backup/SPC0101 - Kryptonite - 3 DOORS DOWN.mp3

_myDestinationAudio.nativePath: F:\songs backup\SPC0101 - Kryptonite - 3 DOORS DOWN.mp3

And the code again:

var _mySourceAudio:File = File.userDirectory.resolvePath( _sourceMinusExt + _extension );

var pathToNewFile:String = File.applicationDirectory.resolvePath (_location + _extension).nativePath;

var _myDestinationAudio:File = new File (pathToNewFile);

try { _mySourceAudio.moveTo(_myDestinationAudio, true);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 04, 2013 Apr 04, 2013

Copy link to clipboard

Copied

Any reason why the _sourceMinusExt + _extension filename is "MM00016 - 3 DOORS DOWN - When I'm Gone.mp3" but the filename gets flipped (in both examples) for _location + extension like "MM00016 - When I'm gone - 3 DOORS DOWN.mp3"? Both of  your examples flip the artist and song name. I don't see you flipping that in your code. Is something missing?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 04, 2013 Apr 04, 2013

Copy link to clipboard

Copied

Yes - that happens before the code you see. The AS3 takes the songs details and creates _sourceMinusExt + ext (original path and file name), and _location + extenstion (desired path and file name). I didn't add it in as it's not really relevent. In fact, for testing purposes, it shouldn't matter what _location is (within file name restrcitions) - as long as _sourceMinusExt + ext points to the original file name (it does - AS3 doesn't fail there), we can use a string instead of _location+extension to tell Flash what we want the file to be renamed to and where to put it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Apr 04, 2013 Apr 04, 2013

Copy link to clipboard

Copied

Here is a long thread about 2038

it  is centered around Digital Editions but it might give you some ideas, what is causing the problem.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 06, 2013 Apr 06, 2013

Copy link to clipboard

Copied

What I mean't by the file name was changing wasn't that it's illegal to do that, just that I saw no relevant code in what was given to look over to do that so I wondered "what else is missing here" that might contain a clue to your issue.

On any of the files you get the error with, have you tried a dedicated string for a filename to move it to just for testing? You mentioned that second file gives you the error every time. See if you can move it to a very basic string like "a.mp3" and see if you get the error. If not then you know to look at the naming logic. If you do get the error then the source file has something protecting it from being copied (did you purchase that specific MP3 with DRM? etc).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 11, 2013 Apr 11, 2013

Copy link to clipboard

Copied

Just about to read through that thread mate.

I did just stumble across a clue...

I made a complete copy of the dir that holds all the files I'm trying to edit. They edited just fine from the new dir. So, from the new dir, I tried to copy two files back to the original dir (overwriting the old files).

Out of the two files I chose to overwrite, one was previously editable, and the other was the one that previously threw the error. The one that  threw the error asked me for administrator permission before allowing me to overwrite it, whereas the previously editable file didn't. So my guess is that I need to ask for permissions somewhere.

This is something I have not delved into before. Any hints? Can you ask for permissions before the desktop app runs, like I see a lot of .NET apps do?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 12, 2013 Apr 12, 2013

Copy link to clipboard

Copied

LATEST

It really seems like the files own permissions/owner are getting involved here. You can always right-click and run the AIR app as administrator but based on your UAC level you may still see a dialog before something the OS considers a system or administrator level change.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines