Click here to Skip to main content
15,892,927 members
Home / Discussions / C#
   

C#

 
AnswerRe: Bắt sự kiện nút ok của hộp thoại print Pin
OriginalGriff24-Mar-12 20:49
mveOriginalGriff24-Mar-12 20:49 
QuestionAuto Connect For HeadSet Pin
Smart Arab24-Mar-12 11:07
Smart Arab24-Mar-12 11:07 
AnswerRe: Auto Connect For HeadSet Pin
Richard Andrew x6424-Mar-12 13:14
professionalRichard Andrew x6424-Mar-12 13:14 
SuggestionRe: Auto Connect For HeadSet Pin
Eddy Vluggen25-Mar-12 3:30
professionalEddy Vluggen25-Mar-12 3:30 
GeneralNokia Blocked my country Pin
Smart Arab25-Mar-12 6:30
Smart Arab25-Mar-12 6:30 
QuestionVisualt Studio 2008 Team Suite for Blackberry Pin
mauricemcse24-Mar-12 2:36
mauricemcse24-Mar-12 2:36 
AnswerRe: Visualt Studio 2008 Team Suite for Blackberry Pin
Wes Aday24-Mar-12 4:36
professionalWes Aday24-Mar-12 4:36 
QuestionThe process cannot access the file because it is being used by another process. Pin
ausia1924-Mar-12 2:34
ausia1924-Mar-12 2:34 
im trying to upload,save the image and then want to move the image to another folder...
only when the control goes to move function i get this error (The process cannot access the file because it is being used by another process.)
//this is my code

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 OnBarcode.Barcode.BarcodeScanner;
using System.Drawing.Imaging;
using System.Diagnostics;
using System.IO;

namespace AutoImageProcessing
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}


private void Form1_Load(object sender, EventArgs e)
{
}

private void label1_Click(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{

OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "*.jpg|*.jpg";
ofd.Multiselect = false;
ofd.Title = "Select JPEG File";
if (ofd.ShowDialog() == DialogResult.OK)
{
textBox1.Text = ofd.FileName;

}






}

private void button2_Click(object sender, EventArgs e)
{
string path = textBox1.Text;
//->if (textBox1.Text != string.Empty)
if (path != string.Empty)
{

try
{
pictureBox1.Image = Image.FromFile(path);

//->String[] barcodes = BarcodeScanner.Scan(textBox1.Text, BarcodeType.All);
String[] barcodes = BarcodeScanner.Scan(path, BarcodeType.All);
// MessageBox.Show(barcodes[0]);

// Specify a "currently active folder"
//string activeDir = @"f:";

//Create a new subfolder under the current active folder
//string newPath1 = System.IO.Path.Combine(activeDir, "export");
string newPath = @"f:/export/" + barcodes[1];
//string newPath = System.IO.Path.Combine(activeDir1, barcodes[1]);

// Create the subfolder
System.IO.Directory.CreateDirectory(newPath);

// Create a new file name. This example generates
// a random string.
string newFileName = barcodes[1];
// Combine the new file name with the path
newPath = System.IO.Path.Combine(newPath, newFileName);


//cropping the signature and photograph
//saving the 2 cropped images into the folder
if (!System.IO.File.Exists(newPath))
{

try
{

Point start = new Point();
Point end = new Point();
int width;
int height;

using (Bitmap bitmap = new Bitmap(pictureBox1.Image))
{
bitmap.Save(newPath + ".jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
bitmap.Dispose();
}
MessageBox.Show("image saved!!!");



start.X = 305;
start.Y = 489;
end.X = 843;
end.Y = 569;
width = 538;
height = 80;
Rectangle imageRectangle = new Rectangle(start.X, start.Y, width, height);

if (start == new Point(0, 0) || end == new Point(0, 0))
{
MessageBox.Show("First select start and end point by clicking on the image");
}
else
{
try
{

pictureBox1.Image = cropImage(pictureBox1.Image, imageRectangle);

using (Bitmap bitmap = new Bitmap(pictureBox1.Image))
{
bitmap.Save(newPath + "_barcode.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
bitmap.Dispose();
}
MessageBox.Show("image saved!!!");



}
catch (Exception ex)
{
MessageBox.Show("this is the error \n" + ex.Message);
}


}



}
catch (Exception ex)
{
MessageBox.Show("An Error has occured: \n" + ex.Message);
}





}

}
catch (Exception ex)
{
MessageBox.Show("An Error has occured: \n" + ex.Message);
return;
}

}

else
{
MessageBox.Show("Please Enter Location of Image");
}
try
{
Image.FromFile(path).Dispose();

MessageBox.Show("entering move function");
Process end=Process.GetCurrentProcess();
MessageBox.Show(end.ToString());
end.Dispose();
end.Close();



}
catch(IOException w)
{
MessageBox.Show("error"+w.Message);
}
try
{
System.IO.File.Move(path, @"f:\img_pr");
MessageBox.Show("move completed");
}
catch (IOException w)
{
MessageBox.Show("error" + w.Message);
}


}





private void pictureBox1_Click(object sender, EventArgs e)
{

}



private Image cropImage(Image image, Rectangle imageRectangle)
{
Bitmap bitmap1 = new Bitmap(image);
Bitmap cropedBitmap = bitmap1.Clone(imageRectangle, bitmap1.PixelFormat);
return (Image)(cropedBitmap);
}

private Image bitmap2(Image image, Rectangle rectangle)
{
throw new NotImplementedException();
}

}
}
AnswerRe: The process cannot access the file because it is being used by another process. Pin
OriginalGriff24-Mar-12 2:51
mveOriginalGriff24-Mar-12 2:51 
AnswerRe: The process cannot access the file because it is being used by another process. Pin
Luc Pattyn24-Mar-12 3:55
sitebuilderLuc Pattyn24-Mar-12 3:55 
AnswerRe: The process cannot access the file because it is being used by another process. PinPopular
Alan N24-Mar-12 4:25
Alan N24-Mar-12 4:25 
GeneralRe: The process cannot access the file because it is being used by another process. Pin
ausia1924-Mar-12 5:38
ausia1924-Mar-12 5:38 
Questionc++ or c# or vb.net Pin
ssssdaaads23-Mar-12 23:52
ssssdaaads23-Mar-12 23:52 
AnswerRe: c++ or c# or vb.net Pin
Abhinav S24-Mar-12 0:08
Abhinav S24-Mar-12 0:08 
AnswerRe: c++ or c# or vb.net Pin
PIEBALDconsult24-Mar-12 3:42
mvePIEBALDconsult24-Mar-12 3:42 
AnswerRe: c++ or c# or vb.net Pin
Wes Aday24-Mar-12 4:33
professionalWes Aday24-Mar-12 4:33 
GeneralRe: c++ or c# or vb.net Pin
Vipin_Arora26-Mar-12 19:39
Vipin_Arora26-Mar-12 19:39 
AnswerRe: c++ or c# or vb.net Pin
ProEnggSoft25-Mar-12 2:33
ProEnggSoft25-Mar-12 2:33 
AnswerRe: c++ or c# or vb.net Pin
Vipin_Arora26-Mar-12 19:31
Vipin_Arora26-Mar-12 19:31 
Questionserver connect Pin
heba abu ghaleih22 23-Mar-12 13:40
heba abu ghaleih22 23-Mar-12 13:40 
AnswerRe: server connect Pin
Richard Andrew x6423-Mar-12 13:53
professionalRichard Andrew x6423-Mar-12 13:53 
GeneralRe: server connect Pin
heba abu ghaleih22 23-Mar-12 14:24
heba abu ghaleih22 23-Mar-12 14:24 
GeneralRe: server connect Pin
Richard Andrew x6423-Mar-12 14:25
professionalRichard Andrew x6423-Mar-12 14:25 
GeneralRe: server connect Pin
heba abu ghaleih22 23-Mar-12 14:27
heba abu ghaleih22 23-Mar-12 14:27 
GeneralRe: server connect Pin
Richard Andrew x6423-Mar-12 14:29
professionalRichard Andrew x6423-Mar-12 14: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.