File.Copy - file with css extension

  • Thread starter Thread starter karen.mcdonagh
  • Start date Start date
K

karen.mcdonagh

I am trying to copy a file with a css extension using the following
code

if (!DoesDirectoryExists(sLocation))
{
//Create the directory
Directory.CreateDirectory(sLocation);
}

FileInfo test = new FileInfo(sFile);

test.CopyTo(sLocation, true);

The location is c:\test.css and the location is c:\test2\test.css

After running this code a directory called test.css is created and no
file is copied.

Any help on this would be greatly appreciated

Thanks
Karen
 
Hi,

You do not need to create a FileInfo, Even so you do not have to check the
existence of the directory.

Directory.CreateDirectory( ) will create the directory path if needed

then use File.Copy( source, target );

Cheers,
 
I am trying to copy a file with a css extension using the following
code

if (!DoesDirectoryExists(sLocation))
{
//Create the directory
Directory.CreateDirectory(sLocation);

This will create the directory sLocation. When sLocation ==
"C:\test2\test.css",
a directory "test.css" will be created in "C:\test2".

You need to specify the directory you want to create without (!) the file
namee. g. "C:\test2".
 
Back
Top