After figuring out the solution to my previous problem while writing an Inkscape extension, I've now gotten to the part wheren the required information is present in my C#/Mono application.
When I try opening (readonly) the file that Inkscape has temporarily created at C:\Users\Remote\AppData\Local\Temp\ink_ext_XXXXXX.svg9XL2MZ
, I get the below error:
Uncaught exception: System.IO.IOException: The process cannot access the file C:\Users\Remote\AppData\Local\Temp\ink_ext_XXXXXX.svg9XL2MZ because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at my.plugin.InkSVG.OpenFile(String location)
at my.plugin.Main(String[] args)
The code in question:
public XElement OpenFile(string location){
Debugger.Debug("Opening file: " + location, 1);
FileStream fs;
fs = new FileStream(location, FileMode.Open, FileAccess.Read, FileShare.Read);
// fs = new FileStream( location, FileMode.Open, FileSystemRights.ReadData, FileShare.Read, 4096, FileOptions.None );
return XElement.Load(fs);
}
Both versions of fs
being instantiated don't work.
The very first method I had, was simply XElement.load(location)
but this opens the file using ReadWrite
permission, something I don't need. Still, using XElement.load(location)
results in a slightly longer stacktrace, but ultimately the same error.
Using Process Explorer and searching for ink_ext_XXXXXX.svg
I found two files, both in use by Inkscape - indicating that the most probable cause is Inkscape opens the files but keeps them to itself... Not usefull for when an extension wants to read them too?