how can i save a file in a new filename

Discussion in 'Software' started by mirage_serv, Aug 14, 2006.

  1. mirage_serv

    mirage_serv Private E-2

    hi to everyone

    hi, i run to some problems, say, i have created a program that take thru the command line arguments say,

    c:\ compress x.bat; how can i save it by using my program such

    c:\compress x.bat "<x.bat.pms>" where x.bat is the original filename and the .pms would be its new extension.

    can somebody help me with this, i'm using vc++ 6.0 to develop the program

    thanks in advance
     
  2. Mada_Milty

    Mada_Milty MajorGeek

    I think that the best method for this would be to use the movefile method of the filesystem object. For example:

    Code:
    option explicit
    
    dim o_filesys
    dim v_file, v_ext
    
    set o_filesys = CreateObject ("Scripting.Filesystemobject")
    
    v_file = "c:\scripts\x.bat"
    v_ext = ".pms"
    
    o_filesys.movefile v_file, v_file + v_ext
    'o_filesys.deletefile v_file
    This will create a new file called x.bat.pms in the c:\scripts directory. IIRC, the original file is kept intact. You can remove it (if necessary) by using the deletefile method of the filesystem object. The command is behind the comment.
     
  3. Mada_Milty

    Mada_Milty MajorGeek

    Oh my apologies! You're using Visual C++ 6.0... I had read VB 6.0.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds