简体   繁体   English

为什么我不能在我的工作目录中创建一个新文件?

[英]Why can't I create a new file in my working directory?

I am using PHPStorm 10.0.3 on Windows 7, and I have had no problems working in my project so far.我在 Windows 7 上使用 PHPStorm 10.0.3,到目前为止,我在我的项目中没有遇到任何问题。 But for some reason, I come into work this morning and suddenly I'm not able to create a new file in any of my directories in my project?但是由于某种原因,我今天早上上班,突然无法在项目的任何目录中创建新文件? This is the error that's occurring:这是发生的错误:

无法在所选目录中创建文件 example.php

The error appears 2 more times after I click OK.单击“确定”后,该错误又出现了 2 次。

I am still able to go into Windows Explorer and create the file manually, so that will tide me over until this problem is resolved.我仍然能够 go 进入 Windows Explorer 并手动创建文件,这样我就可以渡过难关,直到这个问题得到解决。

Thank you all in advance for helping me with such a silly problem.预先感谢大家帮助我解决了这样一个愚蠢的问题。

UPDATE:更新:

It seems PHPStorm thinks the project is "read-only" because when I try and create a new file in the root of the project, I get the error "Cannot modify a read-only directory" followed by the path.似乎 PHPStorm 认为该项目是“只读的”,因为当我尝试在项目的根目录中创建一个新文件时,出现错误“无法修改只读目录”,后跟路径。 I tried using the attrib windows command to remove all read-only attributes but it still hasn't worked.我尝试使用 attrib windows 命令删除所有只读属性,但仍然没有用。

I'm not sure what fixed the problem, but I tried two things and I thought both of them didn't work. 我不确定是什么解决了问题,但是我尝试了两件事,但我认为它们都不起作用。 I'll explain exactly what I did for reference to fix this problem. 我将确切解释我为解决此问题所做的参考。

Firstly, I should announce that I (used to) use Google Drive for all my projects for automated backups. 首先,我应该宣布我(过去)对所有项目都使用Google云端硬盘进行自动备份。 I think that may have messed with the permissions, so I took all my projects out of Google Drive and stopped the process. 我认为这可能与权限搞混了,所以我从Google云端硬盘中取出了所有项目,并停止了该过程。 Didn't fix. 没有解决。

So, I did a combination of the following: 因此,我结合了以下内容:

  1. Right-click on the folder, go Properties, and uncheck the Read-only box and make sure it affected subfolders and files too. 右键单击该文件夹,转到“属性”,然后取消选中“只读”框,并确保它也影响了子文件夹和文件。
  2. Change the permissions on the entire folder so that I was owner, and that "Everyone" had full access to it. 更改整个文件夹的权限,使我成为所有者,并且“每个人”都可以完全访问它。
  3. After both didn't seem to work, I tried making a file in the root directory and noticed something about it being read-only. 两者似乎都无法正常工作后,我尝试在根目录中制作一个文件,并注意到有关该文件为只读的信息。 I found out about Windows' "attrib" command, so I performed "attrib -r -s /S /D project-folder-name " whilst in the parent folder of my directory. 我发现了Windows的“ attrib”命令,因此在目录的父文件夹中执行了“ attrib -r -s / S / D / D project-folder-name ”。 This also didn't seem to work. 这似乎也不起作用。

It was at this point I wanted to know if my other projects in the same directory were affected. 正是在这一点上,我想知道同一目录中的其他项目是否受到影响。 I closed the problem project, opened another project and tried making a file anywhere. 我关闭了问题项目,打开了另一个项目,并尝试在任何地方制作文件。 It worked. 有效。 I tried this for them all. 我为他们所有人都尝试过。 They all worked. 他们都工作了。 So, I went back to the problem directory... and it worked. 因此,我回到了问题目录...并且它起作用了。

I think after making all those changes, I hadn't actually restarted PHPStorm or changed project. 我认为在进行所有这些更改之后,我实际上并没有重新启动PHPStorm或更改过项目。 I recommend, when trying each of my steps above, restart PHPStorm completely or at least change project to make sure the problem project is closed so you can properly test if the step worked. 我建议,在尝试上述每个步骤时,请完全重新启动PHPStorm或至少更改项目以确保问题项目已关闭,以便您可以正确测试该步骤是否有效。

I hope this helps someone in the future. 我希望这对以后的人有所帮助。

On Windows check if the working directory you are trying to save your code to is added to Ransomware protection .在 Windows 上检查您尝试将代码保存到的工作目录是否已添加到勒索软件保护中。 That might be what blocks your IDE from saving files in that specific directory.这可能是阻止您的 IDE 将文件保存在该特定目录中的原因。

You find Ransomware protection by searching for Windows Security .您可以通过搜索Windows Security找到勒索软件保护。 In Windows Security choose Virus & Threat Protection then choose Manage Ransomware Protection and click on Protected folders .在 Windows Security 中选择Virus & Threat Protection然后选择Manage Ransomware Protection并点击Protected folders If the folder is present try removing it from the list of protected folders.如果该文件夹存在,请尝试将其从受保护文件夹列表中删除。

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

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