Advertisement Jump to content
Sign in to follow this  

Quick question regarding files without extensions (C#)

This topic is 4584 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys, I was wondering if you know of a "default" extension the windows might give to a file without an extension? The reason I ask this is that the File.Copy function needs your file to have an extension to be interpreted as a file and not a folder. So File.Copy("C:/myFile", "C:/folder/myFile") would give an error... Anyone know of a clean way to get out of this? I've been googling around but can't seem to find a clean solution that doesn't involve giving the file a fake extension to then remove it. Thanks in advance for any help :)

Share this post

Link to post
Share on other sites
I'd say the "default" file extension is no file extension at all.

If the code you are providing in this thread is the same you use in your app, then maybe that's what causing the error? It should be:
    File.Copy("C:\\myFile", "C:\\folder\\myFile")
    File.Copy(@"C:\myFile", @"C:\folder\myFile")

I wrote a quick app to test, and I successfully copied a file with no extension to another folder. Keep in mind that the location you copy to must exist, i.e. the method is unable to create a new directory, so that is probably the cause of the error.

According to the documentation, the method should expect files as directories is not allowed.

From documentation


The file to copy.
The name of the destination file. This cannot be a directory or an existing file.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!