Wierd bug or by design? Creating a File & Checking IsReadOnly...

1 view
Skip to first unread message

DerekCJ

unread,
Apr 13, 2008, 9:20:18 AM4/13/08
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Hi,

I'm not sure if this a bug or by design.

FileInfo file = new FileInfo(Path.Combine(Path.GetTempPath(),
Path.GetRandomFileName()));
Console.WriteLine((file.Attributes & FileAttributes.ReadOnly) ==
FileAttributes.ReadOnly);

I was expecting it to return false so I can Write a file. Is this
right? I'm on Windows Vista SP1, .NET 2.0 runtime hit.

Thanks,
Derek

Andrew Badera

unread,
Apr 14, 2008, 12:33:05 PM4/14/08
to DotNetDe...@googlegroups.com
Does the process have elevated access to the destination path and file? Are you using a security manifest?
--
--Andy Badera
http://andrew.badera.us/ http://flipbitsnotburgers.blogspot.com/
and...@badera.us
(518) 641-1280
Google me: http://www.google.com/search?q=andrew+badera

Glenn

unread,
Apr 14, 2008, 3:50:30 PM4/14/08
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
The FileInfo constructor does not create the file. The file may
already exist and that may be what is causing it, or the file is not
there at all. Check if it exists!

...Glenn
Reply all
Reply to author
Forward
0 new messages