Topaz Filer - Email filing software
Make file writeable
Messages   Related Types
This message was discovered on microsoft.public.dotnet.languages.vb.


James Kilner
GOOD ANSWER
I am doing file access work and would like to be able to
programmatically make the file writeable. At the moment
when I try to write to a Read-Only file I get an error so
I would like to be able to make the file writeable and
still open the file.
I am using the command
Open "my file.txt" For Input As filenumber

Can anyone help please.
J.
Reply to this message...
Vote that this is a GOOD answer... (2 votes from other users already)
 
 
    
Benoit P.
GOOD ANSWER
dim fiFile as System.IO.FileInfo
fiFile = new System.IO.FileInfo("yourFile")
fiFile.Attributes = System.IO.FileAttributes.Normal

To open a file for writing try that:
dim twFile as System.IO.textwriter
twfile = new System.IO.StreamWriter("yourfile",true) 'true to append

For reading use TextReader and StreamReader.

On Mon, 5 Nov 2001 07:56:52 -0800, "James Kilner"
<Click here to reveal e-mail address> wrote:

[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer... (1 vote from another user already)
 
 
    
Adam Ward
GOOD ANSWER
Hi
You will need a byte array with the contents that you want to write to the file but this should do the trick

Imports System.IO

Dim fs As FileStream
fs = File.Open("c:\demo\demo.txt", FileMode.Open)
fs.Write(YourByteArray, ArrayIndexToStartFrom, MaxNumberOfBytesToWrite)
fs.Close()

Cheers
Adam

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Reply to this message...
Vote that this is a GOOD answer... (1 vote from another user already)
 
 
 
System.IO.File
System.IO.FileAttributes
System.IO.FileInfo
System.IO.FileMode
System.IO.FileStream
System.IO.StreamReader
System.IO.StreamWriter
System.IO.TextReader




Topaz Filer - Email filing software
Ad
BootFX
Reliable and powerful .NET application framework.
Looking to invest in a major software project? Technical and commercial advice available here.
Other Helpful Sites
MBR 247
Topaz Filer
SharePoint Email Filing
Software Advisory Services
 
Copyright © AMX Software Ltd 2008-2010. Portions copyright © Matthew Baxter-Reynolds 2001-2010. All rights reserved.
Contact Us - Terms of Use - Privacy Policy - 4.0.30129.1734