Using a `#` char in a `File` Reference on a network drive cuts the `nativePath` / `url` before the `#`
When pointing to a file on a network drive, which contains a # character in the file path or filename and when the reference begins with file:////, nativePath and url will be cut right before the #.
Attached below is a sample where this can be reproduced:
package
{
import flash.display.Sprite;
import flash.filesystem.File;
import flash.filesystem.FileMode;
import flash.filesystem.FileStream;
import flash.utils.ByteArray;
public class HashtagInFileNameIssue extends Sprite
{
public function HashtagInFileNameIssue()
{
// "networkDrive.com" is a placeholder for an existing network drive, which you can access via Explorer (\\networkDrive.com)
var filename1 : String = "file:////networkDrive.com/test/Hash File ! 123.txt"; // will work
var filename2 : String = "file:////networkDrive.com/test/Hash File # 123.txt"; // will not work. File nativePath/url will be cut before "#"
var filename3 : String = "\\\\networkDrive.com/test/Hash File # 123.txt"; // will work
var valueToSave : String = "test";
// Write to file
var byteArray : ByteArray = new ByteArray();
byteArray.writeUTFBytes(valueToSave);
var newFile : File = new File(filename2);
var fileStream : FileStream = new FileStream();
fileStream.open(newFile,
FileMode.WRITE);
fileStream.writeBytes(byteArray);
fileStream.close();
}
}
}
For filename2 :
file.nativePath will be: \\networkDrive.com\test\Hash File
file.url will be file:////networkDrive.com/test/Hash%20File%20
Having a folder name with a # will cut the name of the folder in the same manner.
Assumption:
I could imagine that the file://// will somehow trigger some kind of URI/URL parsing attempt where the # hashtag indicates something like an Anchor (HTML?) and gets ignored or cut.
I'm not sure if this is working as intended.
Running into this too. We load local HTML and us anchor tags to scroll the user to a specific section.
if (dir.exists) {
loadReference( paragraphReference);
}
protected function loadReference(bookmark:String):void
{
// If a reference window is already open, close it.
if (_refWindow !== null && _refWindow.initialized && !_refWindow.closed) {
_refWindow.close();
}
var dir:File = File.applicationDirectory;
dir = dir.resolvePath("assets");
dir = dir.resolvePath("html");
dir = dir.resolvePath(courseIdentifier);
dir = dir.resolvePath(referenceFileName);
// Open a new reference window
_refWindow = new HTMLWindow();
_refWindow.title = "HTML";
if((Capabilities.os.indexOf("Windows") >= 0)) {
_refWindow.bookmark = bookmark;
}
_refWindow.htmlFilePath = refUrl;
_refWindow.open();
}
On Mac the _refWindow.bookmark causes it to load a white screen