Options

Moving a file to a folder ?

snyktpsnyktp Member Posts: 75
Hello

I want to move a file to a folder. First I created a folder from files' name .After that I want to move the file to the folder. You can see my codes belor ;


NewFolderName:=COPYSTR(FileName,STRLEN(FileName)-1,2);

FolderName := ENVIRON('TEMP')+'\'+NewFolderName;

IF ISCLEAR(NewFolder) THEN
CREATE(NewFolder);

IF NOT NewFolder.FolderExists(FolderName) THEN
NewFolder.CreateFolder(FolderName);

//this part doesnt work
//NewFolder.MoveFile(ENVIRON('TEMP')+ '\'+FileName+'.jpg', -
//ENVIRON('TEMP')+'\'+NewFolderName);

Thank you

Answers

  • Options
    garakgarak Member Posts: 3,263
    For a better help it would be "perfect" if you write what for an type (automation) is NEWFolder and what for an error message pops up

    Here a solution with File System Objet
    //Variables
    //Name	DataType	Subtype	Length
    //FSO	Automation	'Windows Script Host Object Model'.FileSystemObject	
    
    if isclear(FSO) then
      create(FSO);
    
    FSO.MoveFile('C:\Fold1\WS_FTP.LOG','C:\Fold2\');
    clear(FSO);
    

    Regards
    Do you make it right, it works too!
  • Options
    snyktpsnyktp Member Posts: 75
    newfolder - Automation - 'Microsoft Scripting Runtime'.FileSystemObject

    thank you
  • Options
    garakgarak Member Posts: 3,263
    so, you see, it's a good one to give variables unique names ;-)

    Does the codesnippes work or comes an error?
    If error then
      ShowMeTheError;
    
    Do you make it right, it works too!
  • Options
    snyktpsnyktp Member Posts: 75
    You are right. You should see the error if you want to understand the proble ;)
    You can see the error message at the attachment..

    thank you
  • Options
    garakgarak Member Posts: 3,263
    Does the file and the source / destination folder exist?
    You can check this with the virtual table "file" and a filter on "Is File"
    or with FSO.FileExists('C:\Fold1\WS_FTP.LOG');
    Do you make it right, it works too!
  • Options
    snyktpsnyktp Member Posts: 75
    It can find the file..there isnt any problem for finding the file.
    Where is the problem ? I cant see it :(


    StoringFiles(FileName : Text[250])
    NewFolderName:=COPYSTR(FileName,STRLEN(FileName)-1,2);

    //FolderName := ENVIRON('TEMP')+'\'+NewFolderName;
    FolderName := 'C:\Documents and Settings\SY\My Documents\Temp\'+NewFolderName;

    IF ISCLEAR(NewFolder) THEN
    CREATE(NewFolder);

    IF NOT NewFolder.FolderExists(FolderName) THEN
    NewFolder.CreateFolder(FolderName);

    IF EXISTS('C:\Documents and Settings\SY\My Documents\Temp\'+FileName+'.jpg') THEN
    MESSAGE('I found the file');

    NewFolder.MoveFile('C:\Documents and Settings\SY\My Documents\Temp\'+FileName+'.jpg',
    'C:\Documents and Settings\SY\My Documents\Temp\'+NewFolderName);

    CLEAR(NewFolder)
  • Options
    garakgarak Member Posts: 3,263
    Whats the whole value of the variable FileName : Text[250] :?:
    Do you make it right, it works too!
  • Options
    snyktpsnyktp Member Posts: 75
    StoringFiles('127906');

    I just send this value "127906". this is the name of the jpg.
  • Options
    snyktpsnyktp Member Posts: 75
    I use below codes instead of newFolder.MoveFile. It works as I want

    FILE.COPY('C:\Documents and Settings\SY\My Documents\Temp'+ '\'+FileName+'.jpg',
    'C:\Documents and Settings\SY\My Documents\Temp'+'\'+NewFolderName+ '\'+FileName+'.jpg');

    FILE.ERASE('C:\Documents and Settings\SYMy Documents\Temp'+ '\'+FileName+'.jpg');

    Thank you for your answer
Sign In or Register to comment.