某些process.id文件被Windows Server 2012 R2上的某些進程鎖定。
我不能打開它:記事本打敗了他們?
- 寫字板,
- 記事本++,
- 在C#中使用文件共享的各種值
編程,從命令
using (var fileStream = new FileStream(processIdPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) using (var textReader = new StreamReader(fileStream)) { String processIdString = textReader.ReadToEnd(); node.processId = Convert.ToInt32(processIdString); }
「類型」 line:
C:\some-directory> type process.id The process cannot access the file because another process has locked a portion of the file.
IE(是的,我很絕望)
用記事本
我可以打開它到底是如何記事本可以打開鎖定的文件,它沒有別的可以嗎?
編輯
文件鎖定代碼是使用tryLock from FileChannel
val pidFileRw = RandomAccessFile(pidFile, "rw")
val pidFileLock = pidFileRw.channel.tryLock()
基本上它的要求的排他鎖科特林/ JAVA。但仍然記事本得到它。
微軟的奧祕,我有這個錯誤的次數比你有熱食客。我使用一組UNIX工具來擊敗微軟愚蠢的許可協議。採取你的選擇,但我使用cygwin chmod在文件或遞歸,一切都很好。 –
這可能是文件屬性(組/用戶所有權等)和記事本的權限問題。但是,超級用戶可能會獲得更多的里程數。 – informaton
@informaton我剛剛檢查的文件只被標記爲'A'rchive – MonoThreaded