Trying to write a simple C# script to copy file to directory one level up. Here is what I have, but it is sending an error,
“Script.OnActivate()” not all code paths return a value.
and my 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 into the directory one level up from “script/”
The error occurs because you do not return a
boolIf you dont want to return something change you method to return
void, do the following