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

Saving in temp directory

Hi,
I wanted to do the following:
1. Save a file as "Tensegrity.tmp" in my C:\Temp directory (and if one
exists to replace it without any interaction, asking me about it etc.)
2. Once this is done, my application to automatically be minimized.
i.e. in one command, or by the press of one button, my application to save
the file as C:\Temp\Tensegrity.tmp and right after that to be minimized.

I have this so far but all the interaction about where to save the file is
unnecessary to me.
Could someone please help me?
Thanks
J.C.
Private Sub Savetemp_Click()

Dim fs 'As FileSystemObject
Dim OldPath$
OldPath$ = CurDir ' CMDialog will change the current path
Set fs = CreateObject("Scripting.FileSystemObject")

CommonDialog2.Flags = cdlOFNHideReadOnly + cdlOFNExplorer
CommonDialog2.Filter = "*.tmp"
CommonDialog2.Filename = "Tensegrity" ' This is the value returned if
Esc/Cancel

CommonDialog2.ShowSave ' VB 6.0 way to select FileSaveAs

testfile$ = CommonDialog2.Filename ' = "" if the Cancel button is
pressed

If testfile$ <> "" Then
' Check for extension. If it does not exist then insert it.
If GetFileExtension(testfile$) = "Temporary" Then
testfile$ = testfile$ & ".tmp"
End If

saveFile$ = testfile$

' If OverWrite, ask if ok
If Dir(testfile$) <> "" Then
Select Case MsgBox("Overwrite existing file?", vbOKCancel)
Case vbOK
Save (testfile$)
Case Else
Exit Sub
End Select
Else
Save (testfile$)
End If
End If
End Sub
Jul 17 '05 #1
1 5340
See http://www.mvps.org/vbnet/code/system/windirs.htm

--

Randy Birch
MVP Visual Basic
http://www.mvps.org/vbnet/
Please respond only to the newsgroups so all can benefit.
"Jason Charalambides" <da************@netscape.com> wrote in message
news:kx****************@twister.austin.rr.com...
: Hi,
: I wanted to do the following:
: 1. Save a file as "Tensegrity.tmp" in my C:\Temp directory (and if one
: exists to replace it without any interaction, asking me about it etc.)
: 2. Once this is done, my application to automatically be minimized.
: i.e. in one command, or by the press of one button, my application to save
: the file as C:\Temp\Tensegrity.tmp and right after that to be minimized.
:
: I have this so far but all the interaction about where to save the file is
: unnecessary to me.
: Could someone please help me?
: Thanks
: J.C.
:
:
: Private Sub Savetemp_Click()
:
: Dim fs 'As FileSystemObject
: Dim OldPath$
: OldPath$ = CurDir ' CMDialog will change the current path
: Set fs = CreateObject("Scripting.FileSystemObject")
:
: CommonDialog2.Flags = cdlOFNHideReadOnly + cdlOFNExplorer
: CommonDialog2.Filter = "*.tmp"
: CommonDialog2.Filename = "Tensegrity" ' This is the value returned if
: Esc/Cancel
:
: CommonDialog2.ShowSave ' VB 6.0 way to select FileSaveAs
:
: testfile$ = CommonDialog2.Filename ' = "" if the Cancel button is
: pressed
:
: If testfile$ <> "" Then
: ' Check for extension. If it does not exist then insert it.
: If GetFileExtension(testfile$) = "Temporary" Then
: testfile$ = testfile$ & ".tmp"
: End If
:
: saveFile$ = testfile$
:
: ' If OverWrite, ask if ok
: If Dir(testfile$) <> "" Then
: Select Case MsgBox("Overwrite existing file?", vbOKCancel)
: Case vbOK
: Save (testfile$)
: Case Else
: Exit Sub
: End Select
: Else
: Save (testfile$)
: End If
: End If
: End Sub
:
:
Jul 17 '05 #2

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

Similar topics

5
by: Patrick | last post by:
Hello - I am working on a program that creates a small temp file. The ideal would be it creates the file in the user %temp% directory - whatever that is - the default is %USERPROFILE%\Local...
2
by: Carpe Diem | last post by:
Hello all. My host is experiencing some troubles and I think you'll answer me before they can. After I uploaded a slightly changed JScript.NET .aspx page (the contents are not important, could be...
1
by: Joel Zinn | last post by:
am having to change several websites that upload files. Our web master has changed the replication tool and that is causing a problem. We have been using the normal httpInputFile object. It...
10
by: robwharram | last post by:
Hi, I'm quite frustrated in the fact that I can't even display a simple "Hello World" message on .Net. I've been through all of the groups and searched all over the place and haven't been able...
0
by: Andrés G. Aragoneses | last post by:
When trying to use a webservices, not very often I obtain the following exception: Server was unable to process request. ---> Access to the temp directory is denied. Identity 'NT...
14
by: Simon | last post by:
I'm trying to write a little function to save data. Basically I have a large 2d array of structs, so I'm going to have to call the save function once per struct in the array. I'd like to save the...
4
by: Steve | last post by:
When I create a new project in 2005, and I go to save the project files, vb.net displays a dialog box that repeats the name of the application and has a checkbox if I want to create a new directory...
0
by: oritc123 | last post by:
Hello . I am having the following error when I run my application under Windows Vista ( it runs fine under Windows XP ) : "Access to the temp directory is denied. Identity 'ORITSLAPTOP\orit'...
6
by: Aussie Rules | last post by:
Hi, In my application I need to write an XML file to disk, but am concerned that permission might be a problem. The file only needs to be written out and used for another reason and can then...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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,...

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.