Leopardfist
Member
- Joined
- Nov 25, 2014
- Messages
- 14
- Programming Experience
- Beginner
Comments explain how its messed up, or what is going wrong, but I don't know what I did wrong.
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.
//Any ideas what I have done wrong? Code here is incomplete, but the below
//code should give you an idea of how I built my class, and what my
//other function does in assigning values to each class property in the path class.
//I assumed I could call them and use methods on them... like ppath.profile.rename();
//or 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);
}
}
}
}