필터 지우기
필터 지우기

How to create folder using mkdir with permissions to write?

조회 수: 80 (최근 30일)
Kelly Kyriakou
Kelly Kyriakou 2016년 11월 29일
답변: Jordan Reid 2019년 12월 27일
I created a folder using "mkdir", however I can't write files at this folder because the I don't have the permission, the folder is only for read. How to create folder with permission to write?
  댓글 수: 3
Kelly Kyriakou
Kelly Kyriakou 2016년 11월 29일
I used fileattrib('D:\work\results','+w') but nothing changed, the folder is still for read only
Alexandra Harkai
Alexandra Harkai 2016년 11월 29일
Was the return status 1?

댓글을 달려면 로그인하십시오.

답변 (2개)

Jordan Reid
Jordan Reid 2019년 12월 27일
Rather than looking at the permission, look at the directory attribute. I realized that I had used mkdir to create a folder and, for some reason (I suspect it had to do with accidentally using a cell of strings as one of my inputs to create the folder), the directory value was set to zero. When I made the same name directory by hard coding it, the directory attribute was set to 1 and, all of a sudden, I could write files where before it would not allow me. I know this question is old, but I'm providing the answer now for anyone else who runs across this issue and struggles to find an answer like I did.

Jan
Jan 2016년 11월 29일
When you use fileattrib, catch the success and the error message also:
[status,msg,msgID] = fileattrib('D:\work\results','+w')
What do you get? You cannot change the permissions of a folder, if you do not have write permissions to it. Actually you should not even be able to create a folder without write permissions. So how did you create it at first?
Will the problem occur repeatedly? If not, use the Security tab in the "Properties" of the folder, which appears in its context menu in the Windows Explorer. Perhaps the permissions of D:\Work are restricted already. Then fix this folder also.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by