Click here to Skip to main content
15,891,184 members
Home / Discussions / C#
   

C#

 
GeneralRe: Overflow, carry, etc i C# Pin
Jonathan Nethercott26-Mar-13 0:40
professionalJonathan Nethercott26-Mar-13 0:40 
GeneralRe: Overflow, carry, etc i C# Pin
Richard MacCutchan26-Mar-13 1:03
mveRichard MacCutchan26-Mar-13 1:03 
GeneralRe: Overflow, carry, etc i C# Pin
hanzibal226-Mar-13 2:01
hanzibal226-Mar-13 2:01 
GeneralRe: Overflow, carry, etc i C# Pin
Richard MacCutchan26-Mar-13 2:10
mveRichard MacCutchan26-Mar-13 2:10 
AnswerRe: Overflow, carry, etc i C# Pin
parths26-Mar-13 21:20
parths26-Mar-13 21:20 
GeneralRe: Overflow, carry, etc i C# Pin
hanzibal226-Mar-13 22:56
hanzibal226-Mar-13 22:56 
GeneralRe: Overflow, carry, etc i C# Pin
harold aptroot26-Mar-13 23:08
harold aptroot26-Mar-13 23:08 
QuestionFile.Move/create just won't work! Pin
Goaty6510925-Mar-13 11:28
Goaty6510925-Mar-13 11:28 
Hello all, got myself a confusing mess here. I am going to provide as much information as possible, just let me know if something doesn't make sense.

On load, I have a file check and backup that is executed. The backup, doesn't work at all (the Move) and the create, only creates for the first item in the cluster. Here is the code.

C#
//This pulls the current selected item in combo box to the string
string instText = comboInst.GetItemText(comboInst.SelectedItem);

//Items in the combobox have a leading 4 digit number so this
//string simply grabs those 4 digits into a string
string folder = instText.Substring(0, 4);

//This is the path where each item's settings file is located
string path = @"C:\Nightly\Institutions\" + folder + "\\";

//This names each email accordingly
string email = folder + "Email.txt";

//This is the source path for the email file if it exists for
//the backup process
string sourceFile = @"C:\Nightly\Institutions\" + folder + "\\" + folder + "Email.txt";

//this is where the backups go to... it's the above path
//with an archive directory
string destinationFile = @"C:\Nightly\Institutions\" + folder + @"\Archive\";

//now I want to backup a file if it exists, if it doesn't create
//the file...

foreach (string file in settingsFiles)
{
     if (File.Exists(path + email))
     {
           File.Move(sourceFile, destinationFile); 
     }
     if (!File.Exists(path + email))
     {
           Directory.CreateDirectory(path);
           using (File.Create(path + email)) { /*Just creating a path*/ }
      }


What happens is, the file does NOT get moved if the file exists, and when it creates the file if a file doesn't exist, it only does it for the first item in the list, not each as you would expect a foreach statement to process.

If anyone could offer some insight on the wrongdoings of my ways I would appreciate it. Thanks!
AnswerRe: File.Move/create just won't work! Pin
DaveyM6925-Mar-13 11:58
professionalDaveyM6925-Mar-13 11:58 
AnswerRe: File.Move/create just won't work! Pin
Abhinav S25-Mar-13 16:47
Abhinav S25-Mar-13 16:47 
AnswerRe: File.Move/create just won't work! Pin
Richard MacCutchan26-Mar-13 0:02
mveRichard MacCutchan26-Mar-13 0:02 
GeneralRe: File.Move/create just won't work! Pin
Goaty6510926-Mar-13 3:16
Goaty6510926-Mar-13 3:16 
GeneralRe: File.Move/create just won't work! Pin
Richard MacCutchan26-Mar-13 6:37
mveRichard MacCutchan26-Mar-13 6:37 
GeneralRe: File.Move/create just won't work! Pin
Goaty6510926-Mar-13 8:51
Goaty6510926-Mar-13 8:51 
GeneralRe: File.Move/create just won't work! Pin
Richard MacCutchan26-Mar-13 9:14
mveRichard MacCutchan26-Mar-13 9:14 
GeneralRe: File.Move/create just won't work! Pin
Goaty6510926-Mar-13 18:43
Goaty6510926-Mar-13 18:43 
GeneralRe: File.Move/create just won't work! Pin
Goaty6510926-Mar-13 19:42
Goaty6510926-Mar-13 19:42 
GeneralRe: File.Move/create just won't work! Pin
Richard MacCutchan26-Mar-13 22:42
mveRichard MacCutchan26-Mar-13 22:42 
QuestionI want to add progress bar for ftp download for the following code Pin
Friendsaa25-Mar-13 10:25
Friendsaa25-Mar-13 10:25 
AnswerRe: I want to add progress bar for ftp download for the following code Pin
Abhinav S25-Mar-13 16:50
Abhinav S25-Mar-13 16:50 
AnswerRe: I want to add progress bar for ftp download for the following code Pin
GuyThiebaut25-Mar-13 22:39
professionalGuyThiebaut25-Mar-13 22:39 
QuestionWhat is Jabber client ? Pin
Tridip Bhattacharjee25-Mar-13 9:49
professionalTridip Bhattacharjee25-Mar-13 9:49 
AnswerRe: What is Jabber client ? Pin
Peter_in_278025-Mar-13 10:54
professionalPeter_in_278025-Mar-13 10:54 
AnswerRe: What is Jabber client ? Pin
Dave Kreskowiak25-Mar-13 11:01
mveDave Kreskowiak25-Mar-13 11:01 
GeneralRe: What is Jabber client ? Pin
Tridip Bhattacharjee25-Mar-13 21:27
professionalTridip Bhattacharjee25-Mar-13 21:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.