简体   繁体   English

VSCode打开文件被锁定?

[英]VSCode open file to be locked?

All 所有

is it possible to have file locked when opened by VSCode ? 由VSCode打开时,是否可以锁定文件?

any extensions? 任何扩展?

so if I check file by handle64 from sysinternals, it will tell me something like 因此,如果我通过sysinternals的handle64检查文件,它将告诉我类似

> handle64.exe -a c:\XXX.txt

code.exe pid: 123 type: File c:\XXX.txt

Windows solution would be fine, cross-platform would be the best Windows解决方案很好,跨平台最好

The Windows-specific file API ( CreateFile ) has a number of access and sharing options, so yes, technically it would be possible. Windows专用的文件API( CreateFile )具有许多访问和共享选项,因此可以,从技术上讲是可能的。 But that doesn't mean it would be desirable. 但这并不意味着它是可取的。 There are a number of use-cases where it is quite desirable to allow another process to read, change or delete a file while it is "open" (really visible) in vscode. 在许多用例中,非常希望允许另一个进程在vscode中“打开”(真正可见)时读取,更改或删除文件。

I put "open" in quotes because to achieve the behavior it currently has, vscode probably closes the file as soon as it's done reading it, intentionally avoiding the sort of behavior you seem to be asking for. 我将“ open”用引号引起来,因为要实现其当前的行为,vscode可能会在读取完文件后立即将其关闭,从而有意避免了您似乎想要的行为。 Since your question deals with a specific solution, rather than the problem motivating you, it's hard to provide more detail. 由于您的问题是针对特定的解决方案的,而不是因为问题是激励您的问题,因此很难提供更多详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM