codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Creating a file in a different directory...  abhipesit at 07:31 on Tuesday, May 12, 2009
 

Hi...
I need to create a directory and then create a file(regular) within that newly created directory...
I am able to create the directory but i m not able to create a file inside that directory... the file gets created in the current directory... Pls help me out...
Any kind of help will be truly appreciated...

  Re: Creating a file in a different directory...  hermanningjaldsson at 08:02 on Tuesday, May 12, 2009
 

the computer always has some default directory to work in.

to change it just do:

chdir "c:\\somefolder\\":



  Re: Creating a file in a different directory...  S_Flex at 11:30 on Wednesday, May 13, 2009
 

You can try this.

open (my $fh, '>', "location/of/NewDir/MyNew.file") or die $!;
print $fh "File data.....";
close($fh);

or if the file exists on the computer and you want to copy it to the new directory, you can try this.

use File::Copy;
copy("file1","file2") or die "Copy failed: $!";









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Re: Creating a file in a different directory...
•  Auto Populating Lists
•  Unable to display ALL selections from Checkboxlist
•  dropdown list for country,state and city
•  split file column wise
•  Need Javascript Multiple sidebar menu with sliding effects
•  Re: how to create forum using asp.net with c# language?
•  creating user defined service
•  Re: Help with Form--onClick won`t run function


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2009