473,320 Members | 2,162 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,320 software developers and data experts.

changing file extensions with vb.net

1
I am trying to create a text file, fill it with data, then save it as an extension other than .txt, specifically .cfg. How would I go about doing this?
Oct 23 '07 #1
2 1825
Killer42
8,435 Expert 8TB
... then save it as an extension other than .txt, pecifically .cfg. How would I go about doing this?
In VB6 you could just use the Name statement to rename a file. Not sure about VB.Net.

However, probably your best bet is to use the FileSystemObject, both to write the file and to rename it. Look it up in your doco. There's a sample in our VB Articles area that shows how to read a text file using FSO - this should help to get you started, then you can build on that base.
Oct 24 '07 #2
Expand|Select|Wrap|Line Numbers
  1. Imports System.IO
  2. Public Class Form1
  3.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  4.         Dim filestream As New FileStream("C:\file.cfg", FileMode.Create, FileAccess.Write)
  5.         Dim St As New StreamWriter(filestream)
  6.         St.BaseStream.Seek(0, SeekOrigin.End)
  7.         St.WriteLine("Text Line 1")
  8.         St.WriteLine("TText Line 2")
  9.         St.Close()
  10.     End Sub
  11. End Class
Do not forget to import the System.IO namespace else it will not work
Oct 24 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Claire | last post by:
There used to be a nice api call to change a file extension. Is there a class that will do this in c# .net? The FileInfo class will return some information about a queried file. Yes I can query...
3
by: Shapper | last post by:
Hello, I created a script to upload a file. To determine the file type I am using userPostedFile.ContentType. For example, for a png image I get "image/png". My questions are: 1. Where can...
2
by: Dan | last post by:
Hi, I know this code is not entirely javascript, but bare with me. Can you please tell me why this does not work: page: filemanager.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0...
5
by: pb | last post by:
Do anyone know how to change the .aspx extension to something else, say ..sssx, for all or part of a ASP.NET 2.0 site? I recall a Microsoft article on this some time ago, but I cannot locate it.
8
by: marcus.kwok | last post by:
I am having a weird problem and I have can't figure out why it is happening. I create an OpenFileDialog and set a filename filter. When the dialog first opens, the filter works correctly, and...
2
by: antonyliu2002 | last post by:
I am testing AJAX. I've downloaded the AJAX Extension and the CTP December package and installed on BOTH my development machine and the production server. Then I created a very very simple web...
38
by: ted | last post by:
I have an old link that was widely distributed. I would now like to put a link on that old page that will go to a new page without displaying anything.
26
by: Don Calloway | last post by:
I have created a <filename>.db1 (where <filenameis the name given to the database) Access database that is being used in multi-user mode. When the <filename>.db1 file is opened by a user, the...
2
by: mohi | last post by:
hello every one , i want to open a file and then do some processing on it and finally change its name or append something to its name and then save it back . can anyone please help! and also i...
3
by: Davo1977 | last post by:
Does anyone know a regular expression that will rename multiple files that have different extensions to have the same extension. For example, you could use this code when several text files exist in...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.