473,327 Members | 2,069 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,327 software developers and data experts.

file copying

i want to copy a file name C:\\log.text to C:\\ in format of:
C:\\ username-logfile-datetime.txt
yymm & usrname are my global variable

i did:


FileInfo logfile = new FileInfo("C:\\log.txt");
string LFile = "C:\\"+GlobVar.UsrName+"-LogFile-"+GlobVar.YYMM+DateTime.Now.ToShortTimeString()+". txt";

logfile.CopyTo(LFile, true);

i am getting error:
"The given path's format is not supported."
i think problem is due to "DateTime.Now.ToShortTimeString()"
please help me : what sort of error this is.please help
Feb 19 '08 #1
1 895
hey , i got the answer.
when i m asking for current time, it is in this format(3:34)
and we cant use reserved char like :,? for file name.
sloution is take current time in string and replace : by - or any other allowed char
Feb 19 '08 #2

Sign in to post your reply or Sign up for a free account.

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...
5
by: Thomas Lotze | last post by:
Hi, another question: What's the most efficient way of copying data between two file-like objects? f1.write(f2.read()) doesn't seem to me as efficient as it might be, as a string containing...
4
by: HKannen | last post by:
Hi everybody, I'd like to create a link to a file instead of copying the file to the new destination. Is there a possibility to do this ? Is there something like a Link Object in C# .NET ? ...
2
by: TwistedPair | last post by:
All, This is sort of a continuation of a previous post of mine. The code below basically reads a registry key to get a path to a folder and it watches for files created in that folder (only...
18
by: mike3 | last post by:
Hi. I have an interesting problem. The C program presented below takes around 12 seconds to copy 128 MB of data on my machine. Yet I know the machine can go faster since a copying done at a...
4
by: Jim Barlow | last post by:
Does anyone know why K&R2 uses the term "File Copying" at this point (1.5.1)? Also, in the K&R2 answers to exercises maintained by Richard Heathfield, for Listing KRX113 Mr Heathfield repeatedly...
23
by: bc90021 | last post by:
Hi All, Thanks in advance for any and all help! I have this code: g = open(fileName, 'a') where fileName is defined before the line it's used in. It works fine when I use it outside a...
9
by: tdahsu | last post by:
All, I have the following code: for fileTarget in dircache.listdir("directory"): (dirName, fileName) = os.path.split(fileTarget) f = open(fileTarget).readlines() copying = False for i in...
13
by: writeson | last post by:
Hi all, I'm writing some code that monitors a directory for the appearance of files from a workflow. When those files appear I write a command file to a device that tells the device how to...
2
by: raylopez99 | last post by:
Beware newbies: I spent a day before I figured this out: copying a bitmap (image) file to file is not quite like copying a text file--you have to do some tricks (see below), like using a...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
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

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.