Click here to Skip to main content
15,904,156 members
Home / Discussions / C#
   

C#

 
QuestionHow to get Route Map from Bing Map ? Pin
Vijay Kanda29-Mar-14 20:03
Vijay Kanda29-Mar-14 20:03 
Generalneural network code +"SOM" Pin
maryammena28-Mar-14 20:26
maryammena28-Mar-14 20:26 
GeneralRe: neural network code +"SOM" Pin
Pete O'Hanlon28-Mar-14 21:55
mvePete O'Hanlon28-Mar-14 21:55 
GeneralRe: neural network code +"SOM" Pin
harold aptroot28-Mar-14 22:32
harold aptroot28-Mar-14 22:32 
QuestionValidate model on initial request Pin
nitin_ion28-Mar-14 19:02
nitin_ion28-Mar-14 19:02 
AnswerRe: Validate model on initial request Pin
Pete O'Hanlon28-Mar-14 22:26
mvePete O'Hanlon28-Mar-14 22:26 
GeneralRe: Validate model on initial request Pin
nitin_ion30-Mar-14 17:30
nitin_ion30-Mar-14 17:30 
GeneralRe: Validate model on initial request Pin
Pete O'Hanlon30-Mar-14 19:13
mvePete O'Hanlon30-Mar-14 19:13 
GeneralRe: Validate model on initial request Pin
nitin_ion30-Mar-14 19:15
nitin_ion30-Mar-14 19:15 
GeneralRe: Validate model on initial request Pin
Pete O'Hanlon30-Mar-14 20:26
mvePete O'Hanlon30-Mar-14 20:26 
GeneralRe: Validate model on initial request Pin
BobJanova31-Mar-14 0:48
BobJanova31-Mar-14 0:48 
GeneralRe: Validate model on initial request Pin
Pete O'Hanlon31-Mar-14 1:21
mvePete O'Hanlon31-Mar-14 1:21 
GeneralRe: Validate model on initial request Pin
BobJanova31-Mar-14 2:18
BobJanova31-Mar-14 2:18 
AnswerRe: Validate model on initial request Pin
Dave Kreskowiak31-Mar-14 2:14
mveDave Kreskowiak31-Mar-14 2:14 
QuestionRouting event to particular control Pin
samaruf28-Mar-14 16:24
samaruf28-Mar-14 16:24 
QuestionTiff Image Copied with extra bytes Pin
cravi8528-Mar-14 10:50
cravi8528-Mar-14 10:50 
AnswerRe: Tiff Image Copied with extra bytes Pin
Ravi Bhavnani28-Mar-14 11:00
professionalRavi Bhavnani28-Mar-14 11:00 
GeneralRe: Tiff Image Copied with extra bytes Pin
cravi8528-Mar-14 18:26
cravi8528-Mar-14 18:26 
This is the code file. I added onlymain thing. Other manipulations are confidential. So i am sorry for not able to give full code. But this part only related to file operation.

Major methods are ,

File.move , File.Copy.
This is Parellal Process. So i am using Parellal method.

The source code as below


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.Timers;
using System.IO;
using System.Threading;
using System.Threading.Tasks;

namespace AccessSharedFiles
{
public partial class Parellal : Form
{
public Queue queBatch;

public System.Timers.Timer DurationForCopy;
public System.Timers.Timer DurationForProcess;
public bool currentlyProcessing = true;
public bool currentlyCopying = true;
public Parellal()
{
InitializeComponent();
}

private void Parellal_Load(object sender, EventArgs e)
{
try
{
queBatch = new Queue();
DurationForCopy = new System.Timers.Timer();
DurationForCopy.Interval = 5 * 1000;
DurationForCopy.Enabled = true;
DurationForCopy.Elapsed += new ElapsedEventHandler(CopyFiles);

DurationForProcess = new System.Timers.Timer();
DurationForProcess.Interval = 5 * 1000;
DurationForProcess.Enabled = true;
DurationForProcess.Elapsed += new ElapsedEventHandler(ProcessFiles);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}

}

private void CopyFiles(object sender, EventArgs eArgs)
{
try
{
if (currentlyCopying)
{
currentlyCopying = false;
string[] files = Directory.GetFiles( @"C:\SDU\SDU_Parel\Source\");
foreach (string fi in files)
{
File.Move(fi, @"C:\SDU\SDU_Parel\Intermediate\" + fi.Split('\\')[fi.Split('\\').Length - 1].Split('.')[0] + ".tif");
PutFolderinQueue(fi.Split('\\')[fi.Split('\\').Length - 1].Split('.')[0] + ".tif");
break;
}
}
currentlyCopying = true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
currentlyCopying = true;
}
}

private void PutFolderinQueue(string fileName)
{
try
{
string strVal = fileName.ToString();
Monitor.Enter(queBatch);
queBatch.Enqueue(fileName);
Monitor.Exit(queBatch);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

private void ProcessFiles(object sender, EventArgs eArgs)
{
try
{
if (currentlyProcessing)
{
currentlyProcessing = false;
List<string> al = new List<string>();
Monitor.Enter(queBatch);
if (queBatch.Count > 0)
{
for (int intCount = 1; intCount <= queBatch.Count; intCount++)
al.Add(queBatch.Dequeue().ToString().Trim());
}
Monitor.Exit(queBatch);
Parallel.ForEach(al, name => { ProcessBatch(name); });
if (al != null)
{
al = null;
}
currentlyProcessing = true;
GC.Collect();
}
}
catch (Exception ex)
{
currentlyProcessing = true;
MessageBox.Show(ex.Message);
}
}
private void ProcessBatch(string ivalue)
{
try
{
File.Copy(@"C:\SDU\SDU_Parel\Intermediate\"+ivalue, @"C:\SDU\SDU_Parel\Destination\" + ivalue);
File.Delete(@"C:\SDU\SDU_Parel\Intermediate\" + ivalue);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
GeneralRe: Tiff Image Copied with extra bytes Pin
cravi8528-Mar-14 18:38
cravi8528-Mar-14 18:38 
GeneralRe: Tiff Image Copied with extra bytes Pin
Ravi Bhavnani29-Mar-14 4:37
professionalRavi Bhavnani29-Mar-14 4:37 
GeneralRe: Tiff Image Copied with extra bytes Pin
BobJanova31-Mar-14 0:35
BobJanova31-Mar-14 0:35 
GeneralRe: Tiff Image Copied with extra bytes Pin
cravi8531-Mar-14 17:21
cravi8531-Mar-14 17:21 
AnswerRe: Tiff Image Copied with extra bytes Pin
Dave Kreskowiak28-Mar-14 13:02
mveDave Kreskowiak28-Mar-14 13:02 
GeneralRe: Tiff Image Copied with extra bytes Pin
cravi8528-Mar-14 18:39
cravi8528-Mar-14 18:39 
GeneralRe: Tiff Image Copied with extra bytes Pin
Dave Kreskowiak29-Mar-14 3:29
mveDave Kreskowiak29-Mar-14 3:29 

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.