473,320 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

File.Copy - file with css extension


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

Nov 17 '05 #1
2 1786
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,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


<ka************@singularity.co.uk> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...

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

Nov 17 '05 #2
ka************@singularity.co.uk wrote:
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".
}

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

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Luc Saffre | last post by:
Hello, I had a strange problem when freezing (using either py2exe or McMillan installer) a script that imports reportlab (which imports PIL (which imports FixTk))). - Python 2.3.3c (also with...
4
by: b.milbrandt | last post by:
I am trying to convert a unix shell script to perl, and I have having a problem with the portion that copies files based on extension and renaming them in the process. I only trying to copy files...
2
by: Vilmar Brazão de Oliveira | last post by:
Hi, How verify type or extension of file using ASPUPLOAD? I check documentation, but I didn't find anything else yet. thanks, -- ««««««««»»»»»»»»»»»»»» Vlmar Brazão de Oliveira...
6
by: Rob | last post by:
I want to copy files from one folder to another... but only if it is a ".txt" file... Below should work, but how would you filter on ".txt" files only ? Thanks ! Dim fileEntries As String()...
3
by: Phoe6 | last post by:
Hi all, I had a filesystem crash and when I retrieved the data back the files had random names without extension. I decided to write a script to determine the file extension and create a newfile...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
1
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C programming. FYI Although I have called this...
13
by: llothar | last post by:
On windows everything is '.pyd' but there seems to be two ways to get this on unix? Why and what is the rule?
4
by: Noorain | last post by:
Sir I want to CV(doc or pdf format) upload in database. Locally its script run my server but when i hosting it doesn't work. file doesn't upload. Its display, File format is wrong, please try...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.