MATLAB: Can’t create/open txt files

fopentext file

The title pretty much sums it up. I want to use fopen to create or open a file and it is just returning -1 everytime. It seems like Matlab has not the rights to do that but I don't understand why.
I am administrator, I tried running Matlab as admistrator and I know I am in the right folder.

Best Answer

Does the file D:\Work\Stage\filename.txt exist when you try to open it for writing? What do these commands return?
filename = 'd:\Work\Stage\filename.txt'
exist(filename) % Does it exist?
fileattrib(filename) % What permissions do the various groups have to this file?