注释说明了它是如何弄糟的,或者出了什么问题,但是我不知道我做错了什么。
C#:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace testappForHDProgram
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please enter the Employee's Username: ");
string uName = Console.ReadLine();
Console.WriteLine("Please enter the Employee's Profile Server: ");
string server = Console.ReadLine();
Console.WriteLine("Please enter the Computer Number: ");
string sysName = Console.ReadLine();
paths ppath = new paths();
ppath = buildPaths(uName, server, sysName);
verify(ppath);
Console.WriteLine("Starting Job now!");
//My code I entered here is not working like I expected.
//I entered the first couple names of my "ppath" class
//but it does not pop-up any properties or methods for
//me to use to interact with it, it is like it does not recognize ppath.
//Below, when I built the buildPaths function, they worked
//fine for me, and intellisense would pop them up and let me auto enter
//with enter or (). But here, nothing auto pops up.
//任何想法我做错了什么?这里的代码不完整,但是下面
//代码应该让您了解我如何建立我的班级以及我的班级
//其他函数确实为路径类中的每个类属性分配值。
//我以为我可以调用它们并在它们上使用方法...例如ppath.profile.rename();
//或ppath.profile.delete();
}
private static void verify(paths path)
{
bool check = Directory.Exists(path.profile);
if (check)
{
return;
}
else
{
Console.WriteLine("The data you entered was not correct, a complete path could not be verified!");
Environment.Exit(0);
}
}
static paths buildPaths(string uName, string server, string sysName)
{
paths path = new paths();
path.appData = "\\\\" + server + "\\Users\\" + uName + "\\Application Data";
path.citrix = "\\\\" + server + "\\Users\\" + uName + "\\Application Data\\Citrix";
path.citrixTemp = "\\\\" + server + "\\Users\\" + uName + "\\CitrixTemp";
path.cookies = "\\\\" + server + "\\Users\\" + uName + "\\Cookies";
path.icaClient = "\\\\" + server + "\\Users\\" + uName + "\\Application Data\\ICAClient";
path.microsoft = "\\\\" + server + "\\Users\\" + uName + "\\Application Data\\Microsoft";
path.profileUnity = "\\\\" + server + "\\Users\\" + uName + "\\ProfileUnity";
path.sun = "\\\\" + server + "\\Users\\" + uName + "\\Application Data\\Sun";
path.profile = "\\\\" + server + "\\Profiles\\" + uName;
path.profileOld = path.profile + ".old";
path.profileV2 = path.profile + "V2";
path.systemProfile = "\\\\" + sysName + "\\c$\\Documents and Settings\\" + uName;
path.profiles = "\\\\" + server + "\\Profiles";
path.users = "\\\\" + server + "\\Users";
return (path);
}
}
class paths
{
public string profile { get; set; }
public string profileV2 { get; set; }
public string profileOld { get; set; }
public string citrixTemp { get; set; }
public string profileUnity { get; set; }
public string cookies { get; set; }
public string citrix { get; set; }
public string icaClient { get; set; }
public string sun { get; set; }
public string microsoft { get; set; }
public string appData { get; set; }
public string systemProfile { get; set; }
public string users { get; set; }
public string profiles { get; set; }
static bool reName(string path)
{
Directory.SetCurrentDirectory(path.profiles);
if (Directory.Exists(path.profileOld))
{
Directory.Delete(path.profileOld);
}
Directory.Move(path.profile, path.profileOld);
return true;
}
static void Delete(string path)
{
Directory.SetCurrentDirectory("..\\" + path);
try
{
Directory.Delete(path);
}
catch (Exception)
{
Console.WriteLine("Error Deleting :" + path);
}
}
}
}