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: Text wrapping on C# webforms buttons
• Re: Replacing patterns a^b with pow(a,b)
• Re: Problem - Object doesn`t support this property or method
• great sight
• Re: JavaScript: Not working in Firefox 3.x
• Re: Difference between two dates including From & To date
• Re: How to highlight text WITHIN a JTable cell?
• Re: Javascript: return not in function?
• Re: How to concatenate a string and a variable using perl?


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-2010