I'm trying to use a variable to save a file to the same directory where it is, but to no avail. I think I will have to use "Environment.ExpandEnvironmentVariables" but I do not know its application. Can you help me?
using (FileStream streamX = new FileStream (@"\Server\share\rename\%USERNAME%\myfile.pdf", FileMode.Create))
{
stream.WriteTo(streamX);