473,396 Members | 1,858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Remove read-only from file

I need to make sure a file in my site's directory structure is not read-only.
The following code runs after I grant permission to ASPNET on the folder,
but the attribute is not removed (no exceptions thrown).

Dim filePath As String = "c:\inetpub\wwwroot\Test\fileName.xls"
If (File.GetAttributes(xlsTemplateFile) And FileAttributes.ReadOnly) =
FileAttributes.ReadOnly Then
File.SetAttributes(xlsTemplateFile, File.GetAttributes(xlsTemplateFile) Or
FileAttributes.ReadOnly)
End If
Nov 21 '05 #1
1 6604
"smay" <sm**@discussions.microsoft.com> schrieb:
I need to make sure a file in my site's directory structure is not
read-only.
The following code runs after I grant permission to ASPNET on the folder,
but the attribute is not removed (no exceptions thrown).

Dim filePath As String = "c:\inetpub\wwwroot\Test\fileName.xls"
If (File.GetAttributes(xlsTemplateFile) And FileAttributes.ReadOnly) =
FileAttributes.ReadOnly Then
File.SetAttributes(xlsTemplateFile, File.GetAttributes(xlsTemplateFile) Or
FileAttributes.ReadOnly)


Your code is currently /setting/ the read-only bit.

'Or' -> 'And Not'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: madhu | last post by:
Hello I am new to vb.net 1) I have 2 listboxs Named as list1 and list2 and 3 Buttons add and the next one is remove buttons, read button on click of add button the selected item from the...
2
by: Patrick G. | last post by:
Greetings all: ASP VB, SQL Svr 2000 I am pulling data from 3 tables. table1 holds item details table2 holds publication types and the item id from table1 table3 holds category types and...
6
by: Arne Claus | last post by:
Hi If've just read, that remove() on a list does not actually remove the elements, but places them at the end of the list (according to TC++STL by Josuttis). It also says, that remove returns a...
2
by: MFRASER | last post by:
How do I go about looping through a hash table and removing items. I know how do this in a collectionbase, but can't iterate through the hash table with out getting an error. Here is my sample...
31
by: Extremest | last post by:
I have a loop that is set to run as long as the arraylist is > 0. at the beginning of this loop I grab the first object and then remove it. I then go into another loop that checks to see if there...
2
by: wanglei0214 | last post by:
I compiles a program in SLOS, but there is a warning i donot know how to remove? here is the framework of the code: typedef struct device_tree { ...... union {
6
by: tshad | last post by:
Is there a reason to use session.remove over session.contents.remove? Don't they both remove the key and data from the contents collection? I assume that session(x) = nothing does essentially...
5
by: Wing | last post by:
Hello, I am thinking an efficient way to remove all the elements (says they are less than 10) from a container vector<int>. Any suggestion? Thank you.
2
by: Dinsdale | last post by:
I appreciate anyones help here. I've done a whole ton of cool things in C# and am having difficulty expressing those things in VB. In a program I wrote in C# (which I no longer have source for) I...
4
by: coderr | last post by:
Hi all, i have simple question, suppose that we have a ASP.NET web site with lots of local resource files, we can simple delete all of the resource files (resx). Question is, how can remove all of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.