|
|
Kevin
|
|
|
|
|
Hi all,
I have one text file. now i want to check who has taken the handle of the text file.
How can i find the exe in C#?
Reply ASAP.
Thanking You,
Sunil G.modified on Tuesday, February 23, 2010 2:10 AM
|
|
|
|
|
To retrieve a list of running processes use: System.Diagnostics.Process.GetProcesses() which returns an array av Process objects.
|
|
|
|
|
with this System.Diagnostics.Process.GetProcesses() i get all the running processes.
but i want the process name who has taken the handle of particular text file.
As in input parameter i will give textfile name and want the process who has taken the handle of the textfile.modified on Tuesday, February 23, 2010 3:35 AM
|
|
|
|
|
Do you have the name of the text file and you want to retrieve the process which has the handle to that file? Could you please elaborate more?
|
|
|
|
|
Yes you r on the track.
I have the name of the text file and I want to retrieve the process which has the handle to that file..
If you want more explanation, i will explain the whole case.
Thanking You,
Sunil G.modified on Tuesday, February 23, 2010 3:46 AM
|
|
|
|
|
I'm sorry Sunil - don't know how to achieve that. Hope someone else can help, and I'l make a post if I have a sudden stroke of genious.. Good luck anyway!
|
|
|
|
|
Hi
Check this out it might help you..i hav'nt tried it but looks like this is what you are looking for..
fpound this solution while going thrw some blog
posted by :-Gennady Zabrodsky
It is very complex way to invoke Win32 from C#.
You should use tool Handle.exe from http://technet.microsoft.com/en-us/sysinternals/bb896655.aspx
After that your C# code have to be the following:
string fileName = @"c:\aaa.doc";//Path to locked file
Process tool = new Process();
tool.StartInfo.FileName = "handle.exe";
tool.StartInfo.Arguments = fileName;
tool.StartInfo.UseShellExecute = false;
tool.StartInfo.RedirectStandardOutput = true;
tool.Start();
tool.WaitForExit();
string outputTool = tool.StandardOutput.ReadToEnd();
string matchPattern = @"(?<=\s+pid:\s+)\b(\d+)\b(?=\s+)";
foreach(Match match in Regex.Matches(outputTool, matchPattern))
{
Process.GetProcessById(int.Parse(match.Value)).Kill();
}
|
|
|
|
|
|
|
Hi I've been working on making a quadrilateral image distortion algorithm and I have managed to make it distort any image into the shape specified but I cant manage to work out how to apply even bilinear interpolation. I would like some help if anyone can, to add interpolation to my algorithm. I have included the distortion code below:
private Bitmap DistortImage(Image sourceImage,Point TopLeft, Point TopRight, Point BottomLeft, Point BottomRight)
{
int width, height;
width = Convert.ToInt32(Math.Max(p2.X, p4.X));
height = Convert.ToInt32(Math.Max(p3.Y, p4.Y));
Bitmap dest = new Bitmap(width, height);
Bitmap src = new Bitmap(sourceImage);
for (int yStart = TopLeft.Y; yStart < BottomLeft.Y; yStart++)
{
double xStart = TopLeft.X + (((double)(yStart - TopLeft.Y) / (double)(BottomLeft.Y - TopLeft.Y) * (BottomLeft.X - TopLeft.X)));
double yEnd = TopRight.Y + ((double)(yStart - TopLeft.Y) / (double)(BottomLeft.Y - TopLeft.Y)) * (BottomRight.Y - TopRight.Y);
double xEnd = TopRight.X + (((double)(yEnd - TopRight.Y) / (double)(BottomRight.Y - TopRight.Y) * (BottomRight.X - TopRight.X)));
double xScale = (xEnd - xStart) / (double)src.Width;
for (double x = xStart; x < xEnd; x+= xScale)
{
double y = yStart + (((double)(x - xStart) / (double)(xEnd - xStart) * (yEnd - yStart)));
double yScale = ((double)(x - xStart) / (double)(xEnd - xStart)) / ((double)(BottomLeft.Y - TopLeft.Y) / (double)(BottomRight.Y - TopRight.Y));
double ySrc = ((double)(yStart - TopLeft.Y) / (double)(BottomLeft.Y - TopLeft.Y)) * src.Height;
double xSrc = ((double)(x - xStart) / (double)(xEnd - xStart)) * src.Width;
int xNumPixels, yNumPixels;
xNumPixels = Convert.ToInt32(Math.Ceiling(xScale));
yNumPixels = Convert.ToInt32(Math.Ceiling(yScale));
int yNumPixelsAbove;
yNumPixelsAbove = Convert.ToInt32(Math.Ceiling(yNumPixels / 2d));
if (xSrc < 0)
xSrc = 0;
if (ySrc < 0)
ySrc = 0;
Color col = src.GetPixel(Convert.ToInt32(Math.Floor(xSrc)), Convert.ToInt32(Math.Floor(ySrc)));
for (int sx = Convert.ToInt32(Math.Floor(x)); sx < Convert.ToInt32(Math.Floor(x)) + xNumPixels; sx++)
{
if (sx < width)
{
for (int sy = Convert.ToInt32(Math.Floor(y)) - yNumPixelsAbove; sy < Convert.ToInt32(Math.Floor(y)) + yNumPixels; sy++)
{
if (sy >= 0 && sy < height)
dest.SetPixel(sx, sy, col);
}
}
}
}
}
src.Dispose();
src = null;
return dest;
}
Thanks in advance to anyone who can help"I'm very good at multitasking. I can completely ignore you and do this at the same time"
|
|
|
|
|
This is not the speedy solution.
You are mapping your src pixels to your dest pixels. Instead of skipping pixels, just walk through each dest pixel and figure out a double for src x and y. The fractional part of the x and y can be used for weighting your source pixels - bi-linear.
int xSrcIdx = (float)Math.Floor(xSrc);
float xFrac = xSrc - xSrcIdx;
int ySrcIdx = (float)Math.Floor(ySrc);
float yFrac = ySrc - ySrcIdx;
Color c00 = src.GetPixel(xSrcIdx, ySrcIdx);
Color c01 = src.GetPixel(xSrcIdx, ySrcIdx+1);
Color c10 = src.GetPixel(xSrcIdx+1, ySrcIdx);
Color c11 = src.GetPixel(xSrcIdx+1, ySrcIdx+1);
Color c0 = InterpretColor(c00,c01,yFrac);
Color c1 = InterpretColor(c10,c11,yFrac);
Color c = InterpretColor(c0 ,c1 ,xFrac);
dest.SetPixel(Convert.ToInt32(Math.Floor(x)), Convert.ToInt32(Math.Floor(y)), col);
Where InterpretColor(Color c1, Color c2, float frac) returns a linear interpolation between c1 and c2. This will give you some of the smoothing you want. The problem is that when the delta between source pixels >> 1, you start getting visual anomalies, and might want to have another method that combines multiple (> 2x2) pixels back into the dest.Opacity, the new Transparency.
|
|
|
|
|
Thank you for that. Hopefully this will help get me the solution that im after.
Thanks again"I'm very good at multitasking. I can completely ignore that and do this at the same time"
|
|
|
|
|
I compile my form But view warning error
the error message is:Child list for field tblmembers cannot be created
My form Code is:
using System;
using System.Collections.Generic;
using System.Data.OleDb;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using DevComponents.DotNetBar.Rendering;
namespace Library_Project
{
public partial class ViewInfo : Form
{
public ViewInfo()
{
InitializeComponent();
}
private void ViewInfo_Load(object sender, EventArgs e)
{
DataSet dsDataMember = null;
memberBL thisMember = new memberBL();
dsDataMember = thisMember.View();
dataGridViewX1.DataBindings.Add(new Binding("DataSource", dsDataMember, "tblmembers"));
dataGridViewX1.Columns[0].HeaderText = "کد عضو";
dataGridViewX1.Columns[1].HeaderText = "نام عضو";
dataGridViewX1.Columns[2].HeaderText = "نام خانوادگی";
dataGridViewX1.Columns[3].HeaderText = "شماره شناسنامه";
dataGridViewX1.Columns[4].HeaderText = "کد ملی";
dataGridViewX1.Columns[5].HeaderText = "تاریخ تولد";
dataGridViewX1.Columns[6].HeaderText = "شغل";
dataGridViewX1.Columns[7].HeaderText = "تلفن";
dataGridViewX1.Columns[8].HeaderText = "موبایل";
dataGridViewX1.Columns[9].HeaderText = "ادرس";
dataGridViewX1.Columns[10].HeaderText = "تاریخ عضویت";
DataSet dsDataBook = null;
bookBL thisBook = new bookBL();
dsDataBook = thisBook.View();
dataGridViewX2.DataBindings.Add(new Binding("DataSource", dsDataBook, "tblbooks"));
dataGridViewX2.Columns[0].HeaderText = "کد کتاب";
dataGridViewX2.Columns[1].HeaderText = "نام کتاب";
dataGridViewX2.Columns[2].HeaderText = "ناشر";
dataGridViewX2.Columns[3].HeaderText = "مترجم";
dataGridViewX2.Columns[4].HeaderText = "شابک";
dataGridViewX2.Columns[5].HeaderText = "موضوع";
try
{
textBox1.DataBindings.Add(new Binding("Text", dsDataMember, "tblmembers.membercode"));
textBox2.DataBindings.Add(new Binding("Text", dsDataMember, "tblmembers.name"));
textBox3.DataBindings.Add(new Binding("Text", dsDataMember, "tblmembers.family"));
textBox4.DataBindings.Add(new Binding("Text", dsDataMember, "tblmembers.shsh"));
textBox5.DataBindings.Add(new Binding("Text", dsDataMember, "tblmembers.melicode"));
textBox6.DataBindings.Add(new Binding("Text", dsDataMember, "tblmembers.tavalod"));
textBox7.DataBindings.Add(new Binding("Text", dsDataMember, "tblmembers.shoghl"));
textBox8.DataBindings.Add(new Binding("Text", dsDataMember, "tblmembers.tel"));
textBox9.DataBindings.Add(new Binding("Text", dsDataMember, "tblmembers.mobile"));
textBox10.DataBindings.Add(new Binding("Text", dsDataMember, "tblmembers.adr"));
textBox11.DataBindings.Add(new Binding("Text", dsDataMember, "tblmembers.trkhozv"));
}
catch (Exception err)
{
MessageBox.Show(err.Message.ToString());
}
try
{
textBox12.DataBindings.Add(new Binding("Text", dsDataBook, "tblmembers.codebook"));
textBox13.DataBindings.Add(new Binding("Text", dsDataBook, "tblmembers.bookname"));
textBox14.DataBindings.Add(new Binding("Text", dsDataBook, "tblmembers.nasher"));
textBox15.DataBindings.Add(new Binding("Text", dsDataBook, "tblmembers.motarjem"));
textBox16.DataBindings.Add(new Binding("Text", dsDataBook, "tblmembers.shabok"));
textBox17.DataBindings.Add(new Binding("Text", dsDataBook, "tblmembers.mozo"));
}
catch (Exception err)
{
MessageBox.Show(err.Message.ToString());
}
}
private void dataGridViewX1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
textBox1.Text = dataGridViewX1.CurrentRow.Cells[0].Value.ToString();
textBox2.Text = dataGridViewX1.CurrentRow.Cells[1].Value.ToString();
textBox3.Text = dataGridViewX1.CurrentRow.Cells[2].Value.ToString();
textBox4.Text = dataGridViewX1.CurrentRow.Cells[3].Value.ToString();
textBox5.Text = dataGridViewX1.CurrentRow.Cells[4].Value.ToString();
textBox6.Text = dataGridViewX1.CurrentRow.Cells[5].Value.ToString();
textBox7.Text = dataGridViewX1.CurrentRow.Cells[6].Value.ToString();
textBox8.Text = dataGridViewX1.CurrentRow.Cells[7].Value.ToString();
textBox9.Text = dataGridViewX1.CurrentRow.Cells[8].Value.ToString();
textBox10.Text = dataGridViewX1.CurrentRow.Cells[9].Value.ToString();
}
}
}
What is the Problem?
|
|
|
|
|
Do you need to add the schema to the Binding parameter, "mySchema.tblmembers" I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Does anyone know how to insert a Hyperlink into a mail message sent through SMTPClient. I am able to send www.asdf.com within the body of the email, but when I open up my test email, it doesn't show up as a hyperlink.
thank you!
-matt
|
|
|
|
|
You'll need to create a HTML email and insert the hyperlink as usual in there:
<a href="http://www.adsf.com">adsf</a>
|
|
|
|
|
I think that depends mainly on what you are using to view the email with. Some show anything that looks like a web address as a link, some allow html, others not.
What are you using to view the email with and does it work on other URL?CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Please set the value mail.ishtml=true
|
|
|
|
|
Send yourself an email message that includes a hyperlink. When you receive it in your inbox take a look at the raw message to see what has been transmitted. txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
I am porting a Fortran numerical modeling code (console application) to C#. I am new to C#, so I mostly convert Fortran subroutines into C# class methods. My code reads ASCII input to obtain the modeling parameters. The basic method I use to read the input has not changed in 12 years, and I always felt that there should be a better way to do it. Now that I am moving to a new language, would be a good time to learn that better way. In my reading I have seen references to parse trees and other concepts I am not familiar with. I would like to get a few suggestions or references to articles or books that might help me.
Below I show example of my input and code. The basic idea is to read a file line by line, breaking the line into tokens. those tokens are in string[] input. The read method in my InputData class looks for keywords, instantiating objects as appropriate. Each object has its own Read method. Each class with a Read method inherits from the Reader class.
This is a simplified input file. I will probably consider moving to XML input in the future, but right now I have to support this format.
FORMATION
UNITS METERS
TOP 1055
END
Simplified code:
public class Reader
{
protected string readMode = "0";
public virtual void Read(string[] input) { }
}
public class InputData : Reader
{
public Formation formation;
public override void Read(string[] input)
{
if (input.Length == 0) return;
string firstword = input[0];
if (firstword.CompareTo("FORMATIOM") == 0)
{
formation = new Formation();
readMode = "FORMATION";
}
else if (readMode == "FORMATION")
{
formation.Read(input);
}
}
}
public class Formation : Reader
{
protected string depthUnits;
protected double topBoundaryDepth;
public override void Read(string[] input)
{
string firstword = input[0];
if (firstword.CompareTo("UNITS") == 0)
{
depthUnits = input[1];
readMode = "0";
}
else if (firstword.CompareTo("TOP") == 0)
{
topBoundaryDepth = Convert.ToDouble(input[1]);
readMode = "0";
}
}
}<div class="signature"><div class="modified">modified on Monday, February 22, 2010 2:19 PM</div></div>
|
|
|
|
|
You don't need to do the compareTo/ ==0 thing, you can just write if(input[0] == "UNITS") etc
But your code is not formatted..
Ok it is now
An other note, I would probably use an enum for the readmode, but maybe that's just me
|
|
|
|
|
This is my first time posting. I did not realized my formatting would be stripped. I was focused on the message, and did not notice the formatting commands. I edited my original post to indicate code blocks.
I will take any suggestions, even if it does not address my original question. I am very excited about moving on from Fortran after 30 years. I am happy to get new ideas.
|
|
|
|
|
First of all you used:
public override void Read(string[] input)
if (input.Length == 0) return;
The way input is declares as a array of strings. but then it is used as a single string. witch is incorrect syntax. I think you intended to use input.Count . Here I was wrong.
if you want to use ASCII encoding then read this at msdn:
http://msdn.microsoft.com/en-us/library/system.text.encoding.ascii.aspxmodified on Monday, February 22, 2010 12:44 PM
|
|
|
|
|