Here is how I’m creating a file:
System.IO.File.Create(Server.MapPath("..") + name + ".html");
But sometimes name has illegal characters, like å, from the swedish alphabet. How to save them? It is possible directly, but I get error when I do it with code.
If the path is user controlled and potentially contains invalid file system characters then you’ll need to ask the user to change the name or normalize out the bad characters in a deterministic way. One method is to replace all invalid characters with say underscore.
You could then use this function as follows
EDIT
As several people pointed out, it’s best practice to use
Path.Combinehere to combine directory and file names.