Create a temp file with VB.NET
#1
Thumbs Down 

Temp files are generally used for temporary storage and data manipulation. This is often necessary for storing user data, user preferences, session information, application cache, and many other types of information.

In order to get the name of the file that you can use as a temp file in VB.NET, I suggest using the GetTempFileName method of the Path class. While there are multiple approaches to creating a temp file, it's really helpful to use the System.IO.Path because it returns a unique file name in the current user's temporary directory; you can use that file name to create a file for storing temporary information. Note that calling this method multiple times will result in getting a different file name each time even if you don't use that name to create a file. This behavior prevents name collisions between multiple applications.

In my sample code, I define the string variable, sTempFileName, and assign the System.IO.Path.GetTempFileName method's return value to it. This produces a temp file name that I can use. I then create a FileStream object, fsTemp, and request that the system create a file with the filename, sTempFileName. Once the file is created, I add data to it (this code is omitted in the example). After that, the temp file is closed.

Code: [Select]
Code:
Private Sub TempFile()
Dim sTempFileName AsString = System.IO.Path.GetTempFileName()
Dim fsTemp AsNew System.IO.FileStream(sTempFileName, IO.FileMode.Create)


MessageBox.Show(sTempFileName)


'write data to the temp file

fsTemp.Close()


System.IO.File.Delete(sTempFileName)


End Sub
Reply

Important Note..!

If you are not satisfied with above reply ,..Please

ASK HERE

So that we will collect data for you and will made reply to the request....OR try below "QUICK REPLY" box to add a reply to this page
Popular Searches: dack net, seminar of crioge3nic grindingare in vb net, create a biodata using swingt, create a website for college, how to create a student feedback form using vb net, www hobbycircuit net, fabrication of automatic temp controller cooling system,

[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Possibly Related Threads...
Thread Author Replies Views Last Post
  ZFS FILE SYSTEM project topics 1 3,148 08-12-2012, 02:07 PM
Last Post: seminar details
  ADO.NET Application Development Technology computer girl 0 868 05-06-2012, 12:22 PM
Last Post: computer girl
  Minimizing File Download Time in Stochastic peer-to-peer networks electronics seminars 7 7,326 15-03-2012, 12:32 PM
Last Post: seminar paper
  ANT HOC NET seminar projects crazy 2 3,387 13-02-2012, 12:30 PM
Last Post: seminar paper
  AS2 protocol for file transfers Electrical Fan 1 2,923 24-01-2012, 10:09 AM
Last Post: seminar addict
  File Transfer Protocol seminar surveyer 2 2,464 20-01-2012, 10:06 AM
Last Post: seminar addict
  ccsds file delivery protocol full report project reporter 1 1,488 07-01-2012, 03:40 PM
Last Post: project uploader
  Building Blocks of .NET seminar class 0 1,440 25-03-2011, 09:52 AM
Last Post: seminar class
  File Handling seminar class 1 1,972 21-03-2011, 04:10 PM
Last Post: seminar class
  FILE AND RECORDS MANAGEMENT SYSTEM seminar class 0 1,283 22-02-2011, 02:48 PM
Last Post: seminar class

Forum Jump: