Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Moving Around File


if I need to delete a certain line from a file, how can i move to that line in write mode?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Moving A File
Hey there...

I'm wondering how i can move a file. I've been trying the api call, "MoveFile", but i cant seem to get it to work... Anyone??

Thanks,
Jordan

Moving Throughout A File
Hi. Im having trouble with saving in my map editor. This part isnt game related though. What im trying to do is open up a Temp File.. that works fine. but im trying to go to a certain part in it. Like. If i had a tile at 10, 15 i want to go down 15 spaces.. i could do a loop for that easy enough.. but how would i go over? actually in eed it to go over 9 and down 14 then but thats not the point. help appreciated. thanx

Moving A File
It should be simple. I have a file on a networked drive that I want to move to another computer.
Obj.copy doesn't seem to work as the file isn't seen as a declarable object.
How can I do this?

File Moving
VB Code:
filecopy(FullPaths.item(FileNames(x)) , dirPaste.Path)


when i write this line of code to copy files i get a message saying it expects a = sign

fullpaths is a collection with all entries having a key of their file name
Filenames contains the names of the files that are used to reference the paths

File Moving
Hello all,

I have this program where i move files from server to PC and PC to server and so on (you get the idea )

I want to set up a progress bar to display how much time is left, the problem is I have no idea how to do this.

Anybody know how or mabe has an example?

Thanks,
Rudy

File Moving...
I want to know how to move specific files to a different directory. I found some help at http://www.vb-world.net/files/shfileop/ but this isn't exactly what I want to do.

I want to have all files in c:/files that start with the letter A to go to c:/files/A, all files that start with B to go to c:/files/B, etc... To basically alphabetize the files. I'm having trouble figuring out how to do this... do I create some sort of loop that checks each filename, then moves it?

Moving A File
how do i move a file (text document) that the user selects to a designated folder?

Moving A File...
How would I go about moving a specific file, thats in the same folder as the program thats going to move it, to a different folder?

-Thanks

Moving A File
what i want to ask is:

Question: What is the best method to move a file around the network...........?

The methods i have are the 'Name', 'FSO', 'shell32.dd' (which is what i am cuurenlty using), MoveFile/MoveFileEx in the win32 api or is there anything else i'm missing...............

i want to use the fastest most effient method, but i have little info on any of these methods......

Can anyone help?
Thanks
Mark

Moving Data In A File
Hi guys,

I have a little "newbie" problem. I'd like to move all data in a file from offset 720 till the end to offset 640 and further. Is that possible?

Thanks in advance, Jan.

Moving A File From One Folder To Another
Excel 2002 with Visual Basic 6.3

I have a file, say it's called test.txt, in C:. During the course of running a particular macro I would like to find that file, move it and save it to another folder, say C:My Documents.

Any ideas for the procedure?

Thanks

Moving A File Problem
On my MOVE I get... file already exist, when it doesn't.


Private Sub Form_Load()
Dim fs, f, f1, fc, flName
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder("c:workingatlantic")
Set fc = f.Files
For Each f1 In fc
flName = f1.Name
Debug.Print flName
f1.Move ("c:workingatlanticackup")
Next
End Sub

Help Moving The File Created
I got the next codes:



Code:
Private Sub Command1_Click()
On Error Resume Next
If GenerarArchivo(Dir1.List(Dir1.ListIndex) & "" & File1.List(File1.ListIndex)) Then
MsgBox "ECF File Successfuly converted"
File2.Refresh
End If
End Sub

Private Sub Command2_Click()
Shell "c:windows
otepad.exe " + Dir2.List(Dir2.ListIndex) + "" + File2.List(File2.ListIndex), vbNormalNoFocus
End Sub

Private Sub Command4_Click()
On Error Resume Next
If MsgBox("Are you Sure that you want to delete the file:", vbYesNo) = vbYes Then
Kill Dir2.List(Dir2.ListIndex) + "" + File2.List(File2.ListIndex)
File2.Refresh
End If
End Sub

Private Sub Command5_Click()
File2.Refresh
End Sub

Private Sub Command6_Click()
Shell "c:windows
otepad.exe " + Dir1.List(Dir1.ListIndex) + "" + File1.List(File1.ListIndex), vbNormalNoFocus
End Sub

Private Sub Command8_Click()
On Error Resume Next
If MsgBox("Are you Sure that you want to delete the file?", vbYesNo) = vbYes Then
Kill Dir1.List(Dir1.ListIndex) + "" + File1.List(File1.ListIndex)
File1.Refresh
End If
End Sub

Private Sub Command9_Click()
File1.Refresh
End Sub

Private Sub Dir1_click()
File1.Path = Dir1.List(Dir1.ListIndex)
File1.Pattern = "*.txt;*.sel; *.*.txt"
End Sub

Private Sub Dir2_Click()
File2.Path = Dir2.List(Dir2.ListIndex)
File2.Pattern = "*.ECF;*.ECP;*.ECE;*.ECB"
End Sub

Private Sub Drive1_Change()
On Error Resume Next
Dir1.Path = Left$(Drive1.Drive, 1) & ":"
End Sub

Private Sub Timer1_Timer()
End Sub

Private Sub Drive2_Change()
On Error Resume Next
Dir2.Path = Left$(Drive2.Drive, 1) & ":"
End Sub

Private Sub Form_Load()
File1.Path = Dir1.List(Dir1.ListIndex)
File1.Pattern = "*.TXT;*.SEL; *.*.TXT"
File2.Path = Dir1.List(Dir1.ListIndex)
File2.Pattern = "*.ECF;*.ECP;*.ECE;*.ECB"
End Sub
Function GenerarArchivo(ByVal sNombre As String) As Boolean
On Error GoTo Error:
Const HEAD = "TYPE"
Dim iArch1 As Integer
Dim iArch2 As Integer
Dim slinea As String
GenerarArchivo = True
iArch1 = FreeFile
Open sNombre For Input As #iArch1
iArch2 = FreeFile
Open Left(sNombre, Len(sNombre) - 4) & ".ecf" For Output As #iArch2
'paso la primer línea
If Not EOF(iArch1) Then Line Input #iArch1, slinea
stexto = HEAD + slinea
While Not EOF(iArch1)
stexto = stexto + "," + vbCrLf
Input #iArch1, slinea
stexto = stexto + slinea
Wend
Print #iArch2, stexto
Close (iArch1)
Close (iArch2)
Salir:
Exit Function
Error:
MsgBox "Error:" & Err.Description
GenerarArchivo = False
Resume Salir
End Function

What about now?
Sorry for the space.

2 windows where after presing the button create and rename the file but left the file renamed in the directory from the second windows. the problem is that the file is renamed but still in the same dir where I the old file is. Can somebody help me?

Moving Up & Down In File List Box
heyy guyz..

i was wondering...if i have a file list box with many files in it...how can i cause the cursor or watever to move to the next file down or up, to the beginning, and to the end of the list of files (and if possible cause the cursor to move randomly as well)...

and if it does move...under which event would that be?? example: file1_change??

thanxx in advance

Moving In Text File
I have open a text by
open #textfile for input as f_handle

i am moving/reading the file by
line input

if centain condition is not fulfilled i have move a line back ie i have to go to previous line


How i can do that in VB please tell

in foxpro fseek fuction return the current position of the file
which i used for above problem but i dont know how it is used in VB

Please help

Some File Moving Questions
How do u create a new directory?
How do u copy a file from one path to another?

Moving A File Before Saving The New One
I am working on project in EXCEL, using VBA. I have a command button which
creates a text file that gets uploaded into a software package we have.
Before the file gets saved, I want to move the old file into an archive
folder on a network drive.

Can anyone help me with code for this?

Bill Krupinsky
Performax - ISG
1050 Hull Street
Baltimore, MD 21230
410-986-2080
email@removed



Please visit us at www.GetPERFORMAX.com

Note: The information contained in this message may
be privileged and confidential and protected from
disclosure. If the reader of this message is not
the intended recipient, or an employee or agent
responsible for delivering this message to the
intended recipient, you are hereby notified that
any dissemination, distribution or copying of this
communication is strictly prohibited. If you have
received this communication in error, please notify
us immediately by replying to the message and
deleting it from your computer.

Problem - Moving A File Using Variable Name
OK, I have a problem, i`m fairly new to VB so this is probably easy to anyone with some experience.

I have done some importing of files (namely csv's) from a specific directory. Once they are imported, I want to move them to a sub-directory called "processed".

I have been trying to use the "Name.....As" code, for example

Name "C:ADirThisFile.txt" As "C:ThatDirThisFile.txt"

but I need to use a variable name rather than a hard-coded filename. This is because this code is in a loop and the filename of the file to be moved changes with each execution of the loop.

for example

Name filename As ".processed" filename

this obviously doesnt work....any suggestions....????

Moving Multiple .DAT Files Into One .DAT File
I need to move all of the .dat files in a directory to one large .dat file. I have been successful in moving one .dat file at a time, but not the entire directory. Below is the current code that I have. What do I need to change so that all of the files will be read and moved at once?

Here is the code.

VB:

Option Explicit

Private Sub Form_Load()

On Error GoTo Err_Form_Load
'Open Dialog box to select multiple files
With CommonDialog1
.DialogTitle = "Woohoo"
.InitDir = App.Path
.Flags = &H200& + &H4&
.Filter = "Data files (*.dat)|*.dat"
.Action = 1
End With

'Input #1
Open CommonDialog1.FileName For Input As #1

Err_Form_Load:

End Sub

Private Sub cmdRun_Click()

Dim sTemp As String

'Open file to be written to
Open "s: est_fold est2.dat" For Append As #2

Do Until EOF(1)
Input #1, sTemp
Write #2, sTemp
Loop

Close #1
Close #2

End Sub

Moving And Changing Bytes In A File
I've decided to create a EXTREMELY basic encrpytion method that involves moving and swapping bytes in a file. Sure, it's not very secure, but it keeps normal people out of the file . I intend to keep the code very simple, and i intend to just make a library, so that other people can use this in their programs.

What i need to know is how i can change bytes in a file. I've looked through the appropriate seconts of the forum, but to no avail. The appropriate posts either involve binary (too low), or ASCII or some other form of text (too high).

EDIT: I suppose there might be a way to get the binary and mathematically transform it in and out of hexadecimal form, but so far i haven't figured that out.

Moving Multiple File From Filelistbox
Hi All,

I have searched the forum and found some discussions on filelistboxes. I am doing what has already been previously suggested in those discussions but I am not getting the desired result.

I have a list of jpeg images in a filelistbox. The filelistbox multiselect property has been set to 2 - extended. The filelistbox does highlight a block of files when selected (click once on the top file, then hold down the shift key and select somewhere in the middle of the file list box), but when I try to copy the selected files only the last file is copied. My code is attached, any help offered will be greatly appreciated, I am sure it will be something simple


Code:
For i = 0 To FileSub.ListCount - 1
If FileSub.Selected(i) = True Then
TempStr1 = FileSub.Path & "" & FileSub.List(FileSub.ListIndex)
TempStr2 = FileTemp.Path & "" & FileSub.List(FileSub.ListIndex)
FileCopy TempStr1, TempStr2
End If
Next i

FileTemp.Refresh

Alittle Help With 'moving A File Into A Directory'
hi everyone im new here, i was referred by a friend, and i need alittle help on a simple program. it containes two buttons. the first i am using shell to call a program(no problem there)

but i have trouble doing this
i need a button to move c:/Program Files/xxxxxx/xxxxxxxx/splash.jpg to c:/Program Files/xxxxxxxx/xxxxxxxxx/xxxxxxxxx

i put the x'es cause the path is irrelevant. i just need alittle help on how i can move one file into a folder directory


thx alot

~g3nuin3

Alittle Help With 'moving A File Into A Directory'
How about a button to delete c:Program Filesxxxzzzcccsplash.jpg
and then copy c:Program Filesxxxzzzsplash.jpg to c:Program Filesxxxzzzcccsplash.jpg (where we just deleted splash.jpg)

File Moving Without Existing Destination
I have a file that I want to move to a folder however I don't have the same
file in the existing folder. I have a OpenFileDialog that the member uses to
select the file and move the file name into the text box. Then I have a
secondary FolderBrowserDialog that the member uses to select the folder to move it
to. All the selections are made however when I try to move the file it comes
to System.IO.File.Move(Source, Destination) however it doesn't like it
because it says that the Destination Folder already exist I'm not trying to create
the folder I just want to move this file inside of it. Any ideas. Sorry if
this is basic I am trying to learn

Shawn

Moving Through The Files In A File List Box...
Hey everyone,

As the title states I am trying to move through files in a file list box. For example...if the file list box contains 3 files and the user selects all 3 and clicks on a delete button, a loop will be activated like below that will update the selected index and call the delete confirmation each time. The problem is I don't know how to get the selected index to change. I have tried filelistbox1.selectedindex.equals(count) but the selected index never changes from 0. If this isn't clear post back and I'll try to explain it better...any help would be greatly appreciated. Thanks in advance

Code:Dim count As Integer = 0

Do Until count = FileListBox1.SelectedItems.Count
                
                'update selected index so when frmdelete is called it uses the right filename

                frmdelete.show
                count = count + 1
Loop



Edited by - piles on 6/20/2007 8:10:01 AM

Finding Out If A File Is Locked Before Moving It
Hi,

I need to move files from one directory to another during run time, with the file system object.
How can I make sure that the files are not locked (still being written) before I attempt to move them ?
Is there a IsLocked function of some kind ?

Dani

Code For Moving To The First Blank Cell In A Worksheet; Moving Left,right,up Or Down
I have created an application form as a userform in Excel. I need to send the data entered into my text boxes when the program runs to separate excel cells in a worksheet.

My problem is I can use code that will send the textbox entry to a specific cell eg. If my textbox is named Surname I can say

range("a5").value = surname but if I do that when I run the programme to enter the next record for someone else the first record will be overwritten.

I NEED A CODE LINE THAT WILL TAKE ME TO THE FIRST EMPTY CELL AND ALLOW ME TO MOVE DOWN OR TO THE LEFT OR TO THE RIGHT

Moving Or Saving A .mdb File To Another Folder Code
eiy guys,, i need a code that will move or save as my database.mdb
located on C:

and move it to D:/backup/

please give me the code and the proper preferences to click

please email me at pwedepobangmagtanong@yahoo.com

Moving A File From One Folder To Another {updating Hyperlinks}
Thank you!!! I was looking for help moving files from one folder to another.

But I have a question...and this may be a little above my league (started learning VBA a month ago)

After I have moved the files, how do I update my hyperlinks within Excel?

Thanks in advance.

Copy+moving File And Creating Folder That
My first post, this forum is great.

I searched and found how to move a file to a diff. dir using FSO object. Here is my situation. I want to create the destination folder so it displays that days date.

I'm moving "c:projects*.fdd" files ----> c:projects?

Where the question mark is i want a folder created to reflect that days date.

Thanks.

MoveFile Does Not Work When Moving File In A Variable
Hello, I have a form that first it gets the name of the file and stores it in a variable. When I try to do the fso.MoveFile (<souce folder> & <name of the file>),<destination folder> it does not work. If I say "*.*" it will move all files in the source folder but I only want to move the one in the variable. How can I do that?

Thanks.

CODEIf fldr.files.count >= numberOfFiles Then
   
  For Each fil In fldr.files
  
  If Right(fil.ShortName, 3) = "TIF" Then
      If fil.DateLastModified < oldestDate Then
        oldestFile = fil.path
        oldestDate = fil.DateLastModified
      End If
  End If
  
  Next
  
  ShowFileList = oldestFile
   
  MsgBox oldestFile ' show me file name in a msgbox
  
  filename = oldestFile
  
  fso.MoveFile (sfolder & fso.GetFileName(oldestFile)), dfolder
End If

Problem When Moving Connection String To INI File
I've built a COM object that is being used with ASP for my web application. The application works fine, but when I try to move the connection string to an INI file, I start encountering problems. For each class I went into Component Services under the Activation tab, checked 'Enable Object Construction' and entered the path to the INI file in the text box. The code for retrieving the conn string from the INI file is below.

Code:
Private Sub Init()
Dim oInit As Object

   On Error GoTo ErrHndlr
   Set oInit = CreateObject("eSvcsFunctions.cInitValues")
   sConnection = oInit.getConnectionString(sIniLocation, "ConnectionInfo", "Provider", "Server", "User", "password", "database", "InTerNeTAppS03")
   Set oInit = Nothing
   Exit Sub
ErrHndlr:
   App.LogEvent "FISProductdoc.Init: " & Err.Number & ": " & Err.Description
   Err.Raise Err.Number, Err.Source, Err.Description
End Sub



As soon as the 'Enable Object Construction' box is checked I get an error on my ASP page that says 'ActiveX component can't create object'. Any help is appreciated. Thanks in advance.

HELP! Excel Query That Pulls From A Moving File Location
I have what seems like a unique situation. At least I have not found anything similar in searching these forums. If I'm wrong please direct me to a similar thread.
I am working in excel and I need a VB code that will pull a query from another excel file and can be refreshed. I can get that part but I run into a problem when the file that the query is pulling data from is moved. I need the code to propt the user to find the new location and then pull a new query from the new location and put it on the same spot as the previous query.
Please help quickly! I have to get this done and present it in a couple of days.

Thanks in advance for your help.
Nic

Auto Create Missing Folder When Moving File
here's my problem
i want to move the file
"c: estmyfoldermyfile.txt" to "d: estmyfoldermyfile.txt"

but the folder "d: estmyfolder" doesn't exist...

Moving A File And Keeping The Directory Structure In VBScript
Hello, first off, I am going to say this is my first VBScript script.
I do well enough in plain VB, but this is confusing me.

I've been asked to make a script that would copy files from one drive onto another if they were older then a certian date.
So far, this is what I have

Code:

strDriveFrom = "C:" ' Set to the directory you want to copy from
strDriveTo = "D:"' Set to the directory you want to copy to
StartDate = "11/22/2002"' Any file modified after this date will be moved

Set oFS = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFS.GetFolder(strDriveFrom)
Set oSubFolders = oFSFolder.SubFolders

For each folderObject in oSubFolders
Set oFiles = oFS.Drives(strDriveFrom).RootFolder.SubFolders(folderObject).Files
For each fileObject in oFiles
Set oFile = oFS.GetFile(fileObject)
dteFileModified = oFile.DateLastModified
dteFileModified = FormatDateTime(dateModified, 1)
if DateDiff("d", StartDate, Date) < 0 Then



Next



I then hit me that I have no idea how to keep the directory structure, and how to scan sub folders.

Any help would be very much appreciated.

How To Read Event Some One Is Deleting Or Moving File From System In Vb6.0
Hello

Please send me code how to read information when any file or folder delete or move from any drive in system at any time.

Moving Balls To Moving Images??
Please take a look at this as it is related to my question
Thread

is it possible for the create images to be an image type that is already drawn?

Moving Code To Code Behind File Causing Weird Problem...
Hi, I'm wondering if anyone has seen this before...

I wrote an aspx page that had both code and html in the same file. It worked fine. So I decided I would try and move the code to a .vb code behind file so I could link the code to multiple pages without having to edit a million pages of code to fix one issue.

So I move the code over and check dependancies and everything else and it works except for one thing.

I have a radioButtonList that is populated as I loop through a sql datareader. In the first aspx file it adds listitems once and goes onto the rest of the sub. In the vb file however, it seems to be loading everything into the RBL twice. It's as if it is reading the entire sub two times or something.

Any idea what would cause this, and how I can fix it. I'm stumped!

Thanks,
Chris

(urgent, Need Help) Moving File From One Directory To Another Directory Problem
i have a question regarding about the problem that stated at the title.

i need to make sure that after the flat file's data dumped into database then only the particular flat file can be move from one directory to another directory.

i failed to do it, please help

please refer to the attached below

Listbox To Listbox File Moving
I am working on an application where I want to present a current file's field list in one listbox and let the user Click once to highlight it and click a command button to move it from that listbox to another one (for processing). When moved I want it to be gone from the first list and present in the second. Similarly, I have another command button that does the opposite. Can someone give me some ideas of how I actually do this?

Moving
i want to be able to have a pre drawn square in a corner of a form and allow the user to click and drag it to a new location. it sounds simple enough but i am struggling with it. does somebody have a tutorial on this stuff

Moving MDI Bar
I have created a Usercontrol as a menu, when the child forms are maximised the relevant control box for that form is above the Usercontrol, is there anyway to position it below the Usercontrol?

Edit: Ooops! Its an MDI form (maximised) with several children.

Cheers

Moving 360
how do you move a player through 360 so it walks the at 1 or 34 or whatever degrees ?

i attempted throught trig but it had its problems

Code:
Dim dir As Double
Const pi = 3.14159265358979

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyLeft
dir = dir - 10
Case vbKeyRight
dir = dir + 10
Case vbKeyUp
If dir = 90 Then
you.Top = you.Top + 10
Exit Sub
End If
If dir = 180 Then
you.Left = you.Left - 10
Exit Sub
End If
If dir = 270 Then
you.Top = you.Top - 10
Exit Sub
End If
If dir = 360 Then
you.Left = you.Left + 10
Exit Sub
End If

If dir < 90 Then
you.Left = you.Left + 10
you.Top = you.Top + 10 * Tan(dir * pi / 180)
End If
If dir > 90 And dir < 180 Then
you.Left = you.Left - 10
you.Top = you.Top - 10 * Tan(dir * pi / 180)
End If
If dir > 180 And dir < 270 Then
you.Left = you.Left - 10
you.Top = you.Top - 10 * Tan(dir * pi / 180)
End If
If dir > 270 And dir < 360 Then
you.Left = you.Left + 10
you.Top = you.Top + 10 * Tan(dir * pi / 180)
End If

End Select
If dir > 360 Then dir = 0
If dir < 0 Then dir = 360

End Sub

Moving
Ok Iam finding this really difficult to do. Iam able to move a shape upwards using this code.


Shape1.Top = Shape1.Top + Vy
When it reaches a specific point I want it to move in the opposite direction so I included this code.

If Shape1.Top = 160 Then

Shape1.Top = Shape1.Top - Vy
End If
I have put this in the timer but when top = 160 the shape stops moving. Why is this/?? Am I doing something wrong here??

Moving And Looking In D3d
Well, i have done a little 3d world and i want to be able to move in different directories and looking up & down at the same time. I made something, but if i look up(or down) and then turn left(or right) then it rotates the view so, that the camera turns on it's back (**** it's hard to say what you want, if you're not English)

Moving Down One Row
Hi all,

I've tried searching for what, I thought would be simple enough to do, a way to move down one row in my worksheet and select it.

I'm trying to read a table from a database and populate the data into a worksheet.

I've learned how to move to the left (ActiveCell.Next.Select), but after I have written the record, I want to be able to move down to the next row and to the first column.

Here's my code:


Code:
'Starting on row 2 because I have a header.
Range("A2").Select

Do Until rec.AbsolutePosition = adPosEOF

For i = 1 To rec.Fields.Count Step 1 'Loop as many times as there are fields
If ActiveCell.Column = 1 Then
ActiveCell.Value = rec.Fields(i - 1).Value
ActiveCell.Next.Select
Else
ActiveCell.Next.Select
ActiveCell.Value = rec.Fields(i - 1).Value
End If
Next i

rec.MoveNext
'Move down to next row and over to column 1
'I'd like to put "Range(CurrentRow +1 & Column 1).Select" here

Loop

Can't I do this without a row counter?
Any suggestions?
Thanks in advance.

Jason

Moving To Web With VB
If I was interested in integrating some vb into a web page, is it possible and how. Any sites you could recommend would be appreciated. I basically just need to know where to look for some direction in putting forms that function like vb listboxes on a webpage...ones that populate automatically...etc..

Or forms, when they are filled in to capture that data like textboxes..etc for use in building data files ...

Thanks in advance

Moving My Box
I have a shape (box) on my form that I want to have move across the the screen when I click on a command button. I've tried using the following on the command button but it will only work the one time:


Code:

AccVar = true

If AccVar then

Shape1.Left = Shape1.Left + 10

end if
I assume this is because VB only cycles through the code once (on each button click). I tried putting the IF statement in the Form Load but it didn't work because I assume code only triggers when the form loads. What is the best or any way of getting my box to move when the button is pressed?

Is there any tutorials on the web about moving objects in VB?

Moving
OK...

I wanna know how I can make a label move down whenever I press the down key...

can anyone help???

thanks...

Copyright © 2005-08 www.BigResource.com, All rights reserved