Home > OS >  Move a file to %appdata%\ngrokcraft doesnt work. C#
Move a file to %appdata%\ngrokcraft doesnt work. C#

Time:05-25

If possible to help me. So heres the problem: im making a project. and i got a problem every code i try. I have a option "Move server.jar to %appdata%\ngrokcraft% Buuut it doesnt work.

        string a = openFileDialog1.FileName;
    string b = System.IO.Directory.GetCurrentDirectory();
   File.Move(a,b   "AppData\\ngrokcraft\\server.jar");

Can someone help me, also i would preffer aswnering in reply not comments. thanks!

CodePudding user response:

GetCurrentDirectory() is the wrong place to start looking for AppData. Instead, look in Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).

string a = openFileDialog1.FileName;
string b = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
File.Move(a, Path.Combine(b, @"ngrokcraft\server.jar"));
  • Related