filenames

Probability of already existing file System.IO.Path.GetRandomFileName()

僤鯓⒐⒋嵵緔 提交于 2020-01-14 10:32:22
问题 Recently I got the exception: Message: System.IO.IOException: The file 'C:\Windows\TEMP\635568456627146499.xlsx' already exists. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) This was the result of the following code I used for generating file names: Path.Combine(Path.GetTempPath(), DateTime.Now.Ticks + ".xlsx"); After realising that it is possible to create two files in one Tick, I changed the code to: Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + "

What Perl module(s) do I use to obtain an absolute path (including filename) from a relative one on Windows?

Deadly 提交于 2020-01-14 09:21:07
问题 I can only imagine I'm not searching correctly; this seems like an obvious question to be asked here. My apologies if this is a duplicate. I'm writing a Perl program that will take a filename as a command-line argument. I need to convert the filename (or the filename with a relative path attached) to an absolute path (specifically to work with Win32::OLE). I tried using Cwd's 'abs_path', and that almost does what I want, but it returns it using a Unix-style path instead of a Win32 one. Is

Flex: Get self SWF file name?

风格不统一 提交于 2020-01-14 08:46:50
问题 Is there a way I can programmatically determine the filename of the .swf my class is running in? Thanks! 回答1: Stage has a loaderInfo property, which contains a url property that has the information you're looking for. You can get the stage property from any DisplayObject in Flex. trace(stage.loaderInfo.url); 回答2: Just a helpful note: If you load one SWF into another, the loaded (inner) SWF will return an erroneous result if you use loaderInfo.url to try to get the filename. For instance,

Change file name for download and start downloading it after click or delay

痴心易碎 提交于 2020-01-13 16:44:11
问题 I'm looking for php code that changes file name -adds current date, and starts download the file with delay. If download will not start there is an option to download the file with added date by clicking the link. Something like this: Your download will begin in a few moments... If nothing happens, click <a href="">here</a> . I found only this: // It will be called downloaded.pdf header('Content-Disposition: attachment; filename="downloaded.pdf"'); // The PDF source is in original.pdf

Change file name for download and start downloading it after click or delay

谁都会走 提交于 2020-01-13 16:44:09
问题 I'm looking for php code that changes file name -adds current date, and starts download the file with delay. If download will not start there is an option to download the file with added date by clicking the link. Something like this: Your download will begin in a few moments... If nothing happens, click <a href="">here</a> . I found only this: // It will be called downloaded.pdf header('Content-Disposition: attachment; filename="downloaded.pdf"'); // The PDF source is in original.pdf

How to convert strings in any language and character set to valid filenames in Java?

痴心易碎 提交于 2020-01-12 07:54:47
问题 I need to generate file names from user inputted names. These names could be in any language. For example: "John Smith" "高岡和子" "محمد سعيد بن عبد العزيز الفلسطيني" These are use inputted values, so I have no guarantee that the names don't contain characters that are invalid to be in file names. Users will be downloading these files from their browser, so I need to ensure the file names are valid on all operating systems in all configurations. I am currently doing this for English speaking

Bash globbing - autoexpand for a few specific cases?

本秂侑毒 提交于 2020-01-10 10:22:13
问题 I understand that the wildcard * (by itself) will expand in such a way that it means "all non-hidden files in the current folder" with hidden files being those prefixed by a period. There are two use cases that I would think are useful, but I don't know how to properly do: How can you glob for... "All files in the current folder, including hidden files, but not including . or .. "? How can you glob for... "All hidden files (and only hidden files) in the current folder, but not including . or

cmd line rename file with date and time

∥☆過路亽.° 提交于 2020-01-09 18:22:05
问题 Project moving forwards, I can see why creating .bat files to do things can become addictive! I can now save somefile.txt at regular intervals, I then rename somefile.txt by adding the time and date to create a unique file name ren somefile.txt somefile_%time:~0,2%%time:~3,2%-%date:~-10,2%%date:~3,2%%date:~-4,4%.txt As an example, the code above has just renamed somefile.txt to somefile_1317_13022011.txt (1317hrs on 13th February 2011) I ran ren somefile.txt somefile_%time:~0,2%%time:~3,2%-

cmd line rename file with date and time

十年热恋 提交于 2020-01-09 18:21:14
问题 Project moving forwards, I can see why creating .bat files to do things can become addictive! I can now save somefile.txt at regular intervals, I then rename somefile.txt by adding the time and date to create a unique file name ren somefile.txt somefile_%time:~0,2%%time:~3,2%-%date:~-10,2%%date:~3,2%%date:~-4,4%.txt As an example, the code above has just renamed somefile.txt to somefile_1317_13022011.txt (1317hrs on 13th February 2011) I ran ren somefile.txt somefile_%time:~0,2%%time:~3,2%-

Safe to use random numbers to make filenames unique?

纵饮孤独 提交于 2020-01-07 09:45:08
问题 I'm writing a program which basically processes data and outputs many files. There is no way it will be producing more than 10-20 files each use. I just wanted to know if using this method to generate unique filenames is a good idea? is it possible that rand will choose, lets say x and then within 10 instances, choose x again. Is using random(); a good idea? Any inputs will be appreciated! Random rand = new Random (); int randNo = rand.Next(100000,999999)l using (var write = new StreamWriter(