Connecting Tech Pros Worldwide Forums | Help | Site Map

Change file type in vb / vb.net

jamesd0142's Avatar
Needs Regular Fix
 
Join Date: Sep 2007
Location: Wales
Posts: 467
#1: Oct 10 '07
Ok here's one for the experts...

I want to create a text file "test.text" that stores different values on each line.

Is it possible for me to go to the directory its saved and change the extension to test.abc, then when i open it in vb/vb.net is converts the file back to test.text before opening it.

So in english...
I have a file called test.abc, which is technically a notepad file that storing values that i dont want beginers to open. (Dont worry values will be encrypted anyways :))
Then when i read from it needs the extension changed from .abc to .text again before opening it to read the values in vb.

is this possible?

Thanks James

jamesd0142's Avatar
Needs Regular Fix
 
Join Date: Sep 2007
Location: Wales
Posts: 467
#2: Oct 10 '07

re: Change file type in vb / vb.net


Answer my own question again :)

It is possible
i used this.
FileSystem.Rename("Filename", "Filename2")
Ali Rizwan's Avatar
Banned
 
Join Date: Aug 2007
Location: Lahore Pakistan
Posts: 929
#3: Oct 10 '07

re: Change file type in vb / vb.net


Quote:

Originally Posted by jamesd0142

Answer my own question again :)

It is possible
i used this.
FileSystem.Rename("Filename", "Filename2")

Hey buddy,

Dont use fso.rename

If you have made test.abc using notepad or you have made this textfile using fso you can open it in vb either file extension is txt or anyone else like jpg, bmp, abc, mon, it can be a sys file or a exe file.
I ll send you a sample but not now after some time because i have to logout now.
But

GOODLUCK
And Wait for the sample unless you ma de it yourself
ALI
jamesd0142's Avatar
Needs Regular Fix
 
Join Date: Sep 2007
Location: Wales
Posts: 467
#4: Oct 10 '07

re: Change file type in vb / vb.net


ok cheers for that.

so if i understand... you can read lines from a text file, even tho the extenstion is no longer .text/.txt?

Thanks
Moderator
 
Join Date: Oct 2006
Location: Australia
Posts: 7,748
#5: Oct 11 '07

re: Change file type in vb / vb.net


Quote:

Originally Posted by jamesd0142

so if i understand... you can read lines from a text file, even tho the extenstion is no longer .text/.txt?

Correct. The extension is of no significance whatever. It's just to give the user some idea of what to expect, and to determines how Windows treats the file by default.

In other words, if you have a file with a .TXT extension and you just tell Windows to open it, it will start up Notepad (or TextPad, or whatever application you have said TXT files belong to). But you can also tell it to "open with ..." any program you want. In other words, the extension is sort of a "hint" as to who would normally be expected to deal with the file, but this is not enforced.
Reply