473,750 Members | 2,225 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What's the best way to delete read-only files?

Using VB .NET 2003, I need to delete some read-only files.
I tried using System.IO.File. Delete(filename ) - but when the files are
read-only, I get error messages stating that I don't have proper access...

So, what's the best way to delete a read-only file programmaticall y?

Any help would be greatly appreciated!
Jan 18 '06 #1
2 9987
How about changing the attributes so that it is not readonly, then delete
it?

"hz****@nopost. com" <hz************ *@discussions.m icrosoft.com> wrote in
message news:F6******** *************** ***********@mic rosoft.com...
Using VB .NET 2003, I need to delete some read-only files.
I tried using System.IO.File. Delete(filename ) - but when the files are
read-only, I get error messages stating that I don't have proper access...

So, what's the best way to delete a read-only file programmaticall y?

Any help would be greatly appreciated!

Jan 18 '06 #2
There's probably another way, but how about:

System.IO.File. SetAttributes(" C:\test.txt", IO.FileAttribut es.Normal)

Then delete...?

Jay Taplin, MCP
Jan 18 '06 #3

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

Similar topics

0
1508
by: Dave C. | last post by:
Hi there, We have some code that empties a table. Originally, the code used "delete from", but I am told that this method was either too slow, or held a lock for too long (this was a long time ago and I wasn't involved at that point, so I'm not 100% sure exactly the nature of this problem). So the code was changed to "truncate table". Now however, this table is being replicated, so truncate table is no longer an option. I need to change...
11
9267
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in C++. I find my self sometimes, trying Object app = Object(); Object *app = Object(); Object app = new Object();
5
1855
by: Ken | last post by:
Hi. I know it is recommended that exceptions should be caught by reference, but are there recommendations for how an exception should be thrown? Or is it just a matter of throwing a type that is compatiple with the catch. If that is the case, I suppose that if you are catching a reference to exception e, the exception being thrown better be an instance of e or a reference to an instance of e (ie., if you threw a pointer to e and caught...
6
2577
by: Alfonso Morra | last post by:
I have written the following code, to test the concept of storing objects in a vector. I encounter two run time errors: 1). myClass gets destructed when pushed onto the vector 2). Prog throws a "SEGV" when run (presumably - attempt to delete deleted memory. Please take a look and see if you can notice any mistakes I'm making. Basically, I want to store classes of my objects in a vector. I also have three further questions:
19
2606
by: Xavier Décoret | last post by:
Hi, I long thought one could not delete a const pointer but the following code compiles under g++ and visual net: class Dummy { public: Dummy() {} ~Dummy() {}
1
4841
by: TheSteph | last post by:
Hi, I need some Advice.. What is the best practice to execute multiple "nonQuery" SQL operations in a transaction ? 1) Execute all in one "sqlCommand.ExecuteNonQuery();" : sqlCommand.CommandText =
5
8091
by: mkaushik | last post by:
Hi everyone, Im just starting out with C++, and am curious to know how "delete <pointer>", knows about the number of memory locations to free. I read somewhere that delete frees up space assigned to <pointerby "new". Does "new" create a list of pointer names and the size of the memory array they point to? I also read that some compilers may store the number of consec mem locations a pointer points to, just before the first data...
2
2756
by: dasilva109 | last post by:
Hi guys I am new to C++ and need urgent help with this part of my code for a uni coursework I have to submit by Thursday //ClientData.h #ifndef CLIENTDATA_H #define CLIENTDATA_H #include <string>
3
1775
by: dizzy | last post by:
Hi I wonder if this code is standard conformant and should work on all conformant implementations (for some type T): 1: void* mem = ::operator new(sizeof(T)); 2: T* p = new(mem) T(args...); 3: delete p; line 2 I know it should be fine because global operator new should return
19
10760
by: Daniel Pitts | last post by:
I have std::vector<Base *bases; I'd like to do something like: std::for_each(bases.begin(), bases.end(), operator delete); Is it possible without writing an adapter? Is there a better way? Is there an existing adapter? Thanks, Daniel.
0
9577
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9339
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8260
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6804
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4713
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4887
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3322
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2804
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2225
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.