tagged [filenames]

Obtaining only the filename when using OpenFileDialog property "FileName"

Obtaining only the filename when using OpenFileDialog property "FileName" I am trying to include only the filename of the file I've selected in the OpenFileDialog in the label1.Text property, but I ha...

9 Apr at 23:8

Convert DateTime.Now to a valid Windows filename

Convert DateTime.Now to a valid Windows filename I have had this issue quite a few times and have just been using a workaround but thought I would ask here in case there is an easier option. When I ha...

24 Oct at 10:15

Turn a string into a valid filename?

Turn a string into a valid filename? I have a string that I want to use as a filename, so I want to remove all characters that wouldn't be allowed in filenames, using Python. I'd rather be strict than...

28 Nov at 02:18

Given a filesystem path, is there a shorter way to extract the filename without its extension?

Given a filesystem path, is there a shorter way to extract the filename without its extension? I program in WPF C#. I have e.g. the following path: and I want to extract `hello` from it. The path is a...

Build the full path filename in Python

Build the full path filename in Python I need to pass a file path name to a module. How do I build the file path from a directory name, base filename, and a file format string? The directory may or ma...

19 Jul at 14:56

What is the best way to combine a path and a filename in C#/.NET?

What is the best way to combine a path and a filename in C#/.NET? What is the best way to combine a path with a filename? That is, given `c:\foo` and `bar.txt`, I want `c:\foo\bar.txt`. Given `c:\foo`...

15 Jun at 00:12

DateTime.ToString() format that can be used in a filename or extension?

DateTime.ToString() format that can be used in a filename or extension? I want to add a timestamp to filenames as files are created but most of the DateTime methods I've tried output something with sp...

19 Sep at 17:42

How can I replace (or strip) an extension from a filename in Python?

How can I replace (or strip) an extension from a filename in Python? Is there a built-in function in Python that would replace (or remove, whatever) the extension of a filename (if it has one)? Exampl...

15 Jun at 15:26

How would you make a unique filename by adding a number?

How would you make a unique filename by adding a number? I would like to create a method which takes either a filename as a `string` or a `FileInfo` and adds an incremented number to the filename if t...

14 Jul at 17:46

Directory.GetFiles doesn't pick up all files

Directory.GetFiles doesn't pick up all files I have some code that is meant to get files in a directory, which is simple enough The files are named as follows: My issue is that i

31 Jan at 08:38

C# Filepath Recasing

C# Filepath Recasing I'm trying to write a static member function in C# or find one in the .NET Framework that will re-case a file path to what the filesystem specifies. Example: I've tried the follo

cmd line rename file with date and time

cmd line rename file with date and time 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 so...

12 Nov at 16:29

Sanitizing strings to make them URL and filename safe?

Sanitizing strings to make them URL and filename safe? I am trying to come up with a function that does a good job of sanitizing certain strings so that they are safe to use in the URL (like a post sl...

20 Jun at 11:45

Git copy file preserving history

Git copy file preserving history I have a somewhat confusing question in Git. Lets say, I have a file `dir1/A.txt` committed and git preserves a history of commits Now I need to copy the file into `di...

1 Aug at 08:4

Checking collision in filename search patterns with wildcards

Checking collision in filename search patterns with wildcards I need to compare file system wildcard expressions to see whether their results would overlap, by only examining/comparing the expressions...