How to write a simple C# script to copy file to directory one level up? -
How to write a simple C# script to copy file to directory one level up? -
trying write simple c# script re-create file directory 1 level up. here have, sending error,
"script.onactivate()" not code paths homecoming value.
and code:
using system; using system.collections.generic; using system.componentmodel; using system.drawing; using system.text; using system.text.regularexpressions; using system.io; using system.windows.forms; using system.globalization; class script : copyfile { public static bool onactivate() { copydatafile("script/file.js", "../file.js"); } }
solved! using system; using system.io; class script : copyfile { public static void onactivate() { fileinfo myfile = new fileinfo("script/file.js"); myfile.copyto(myfile.directory.parent.fullname + "\\" + myfile.name); } }
this moves file.js directory 1 level "script/"
the error occurs because not homecoming bool
public static bool onactivate() { copydatafile("script/file.js", "../file.js"); homecoming true; }
if dont want homecoming alter method homecoming void
, following
public static void onactivate() { copydatafile("script/file.js", "../file.js"); }
msdn void operator evaluates expression, , returns undefined. useful in situations want look evaluated not want results visible remainder of script.
c# file copy move
Comments
Post a Comment