filenames

C# - Append Number To File Being Saved

我的梦境 提交于 2019-11-30 14:05:14
I have created a screenshot program and all is working great. The only problem is, I am not sure how I can make it so the screenshots are saved with appending numbers. Example: Screenshot 1, Screenshot 2, Screenshot 3, Screenshot 4, etc. Obviously this could be applied to other files being saved. Any ideas? Thank you. Here is a method I use frequently for this very case. Just pass in a string like "Screenshot" and it will find the lowest available filename in the format of "Screenshot [number]" (or just "Screenshot" if there aren't any already): private string GetUniqueName(string name, string

How to create a filename with a trailing period in Windows?

血红的双手。 提交于 2019-11-30 14:04:44
问题 How does one work with filenames that end in a period in Python? According to MSDN's site, such filenames are valid in Windows, but whenever I try to create one in Python, it removes the final period. I even tried creating a raw file descriptor with os.open, but it still removes the period. For example, this will create a file simply named ' test ' os.open('test.', os.O_CREAT | os.O_WRONLY, 0777) Edit: Here is the exact quote About spaces and dots in filenames and directories. The limits are

Association between naming classes and naming their files in python (convention?)

寵の児 提交于 2019-11-30 12:25:00
问题 In python (and some other languages) I have learned, that the name of a class should be written in small letters except for the first letter, which should be a capital letter. Example: class FooBar: ... A class should go in a file, named the same as the class. In this example it would be a file foobar.py . If I want to import the class foo somewhere I have to do this: from foobar import FooBar This convention confuses me a little. My intuition tells me, that if the filename indicates a class,

What characters are allowed in a iOS file name?

不打扰是莪最后的温柔 提交于 2019-11-30 11:02:52
I'm looking for a way to make sure a string can be used as a file name under iOS. I'm currently in the section of the code that deletes incompatible characters. I'm wondering if I'm doing it right. NSString *filename = @"A file name"; fileName = [fileName stringByTrimmingCharactersInSet: [NSCharacterSet controlCharacterSet]]; fileName = [fileName stringByTrimmingCharactersInSet: [NSCharacterSet newlineCharacterSet]]; I'm also wondering if there's already a method that validates a string as a file name. Thank you for your advice! Erik B First of all, you're using the wrong method. Trimming the

How can I sanitize a string for use as a filename?

醉酒当歌 提交于 2019-11-30 10:39:36
问题 I've got a routine that converts a file into a different format and saves it. The original datafiles were numbered, but my routine gives the output a filename based on an internal name found in the original. I tried to batch-run it on a whole directory, and it worked fine until I hit one file whose internal name had a slash in it. Oops! And if it does that here, it could easily do it on other files. Is there an RTL (or WinAPI) routine somewhere that will sanitize a string and remove invalid

Android filename with white space cannot be opened

一个人想着一个人 提交于 2019-11-30 10:18:36
My code works correctly while opening a file in sdcard. However, if I open a filename with white space then error occurs (example: Path - "/sdcard/download/hello hi.jpg"). I tried string.replace(" ","%20"); it doesn't work try { File file = new File(paths); if (file.exists()) { Uri path = Uri.fromFile(file); Intent intent = new Intent(Intent.ACTION_VIEW); String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(MimeTypeMap.getFileExtensionFromUrl(paths)); if (!mimeType.equals("")) { intent.setDataAndType(path, mimeType); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

How to create a filename with a trailing period in Windows?

▼魔方 西西 提交于 2019-11-30 09:21:10
How does one work with filenames that end in a period in Python? According to MSDN's site, such filenames are valid in Windows, but whenever I try to create one in Python, it removes the final period. I even tried creating a raw file descriptor with os.open, but it still removes the period. For example, this will create a file simply named ' test ' os.open('test.', os.O_CREAT | os.O_WRONLY, 0777) Edit: Here is the exact quote About spaces and dots in filenames and directories. The limits are in the windows shell -- not in Windows or NT. Using 'bash', you can create files with spaces (or dots),

Safe/Allowed filename cleaner for .NET

旧巷老猫 提交于 2019-11-30 08:37:10
问题 Is there any standardized / libraried / tested way in .NET to to take an arbitrary string and mangle it in such a way that it represents a valid file name? Rolling my own char-replace function is easy enough, but I'd like something a little more robust and resued. 回答1: This problem is not as simple as you may think. Not only are the characters in Path.GetInvalidFileNameChars illegal, there are several filenames, such as "PRN" and "CON", that are reserved by Windows and cannot be created. Any

Delete Files with same Prefix String using Java

不打扰是莪最后的温柔 提交于 2019-11-30 07:46:32
问题 I have around 500 text files inside a directory with a same prefix in their filename say dailyReport_ . The latter part of the file is the date of the file. (For eg. dailyReport_08262011.txt , dailyReport_08232011.txt ) I want to delete these files using a Java procedure (I could go for a shell script and add it a job in the crontab but the application is meant to used by laymen). I can delete one single file using something like this try{ File f=new File("dailyReport_08232011.txt"); f.delete

Git error: Malformed input or input contains unmappable chacraters

做~自己de王妃 提交于 2019-11-30 07:34:58
问题 My Eclipse workspace has two projects, one using CVS, the other Git. When modifying a file in the CVS project and save, a pop-up window appear saying An internal error occurred during: "Computing Git status for repository repo23". Malformed input or input contains unmappable chacraters: /Users/pb/repo23/对照表/feng11.htm Any idea how to fix this? EDIT: Eclipse Platform Version: 4.3.1.v20130911-1000 Build id: M20130911-1000 Eclipse EGit 3.2.0.201312181205-r 回答1: You can see the exact call stack