Inkscape扩展名:我无法打开临时ink_ext_XXXXXX.svg文件,因为Inkscape本身正在使用它

时间:2018-08-06 11:27:47

标签: c# filestream inkscape

在编写Inkscape扩展名之后,找出了my previous problem的解决方案之后,我现在进入了在C#/ Mono应用程序中存在所需信息的部分。

当我尝试打开(只读)Inkscape在C:\Users\Remote\AppData\Local\Temp\ink_ext_XXXXXX.svg9XL2MZ上临时创建的文件时,出现以下错误:

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)

相关代码:

    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);
    }

实例化的fs的两个版本均不起作用。
我使用的第一个方法就是XElement.load(location),但这是使用ReadWrite权限打开文件的,这是我不需要的。不过,使用XElement.load(location)会导致堆栈跟踪稍长一些,但最终会出现相同的错误。

使用Process Explorer并搜索ink_ext_XXXXXX.svg,我发现有两个文件,两个文件都被Inkscape使用-表示最可能的原因是Inkscape打开了文件,但保留了它们自己。也想阅读吗?

0 个答案:

没有答案