|
It´s difficut to explain it!
I have a Server and a Client. the Client have many Buttons for examble open Word , shutdown,...
When i use this code in the Server i can click on open Word or shutdown both works!
if (get == "rWord")<br />
System.Diagnostics.Process.Start("winword");<br />
if (get == "rExcel")<br />
System.Diagnostics.Process.Start("excel");<br />
string[] get_Split = get.Split('~');<br />
int time = Convert.ToInt32(get_Split[1]);<br />
if (get.Contains("rshutdown"))<br />
{<br />
System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString());<br />
}<br />
}
When i use this code where the sring[] is on the front place i can´t open word! but i can shutdown the Pc in x sec!?
<br />
string[] get_Split = get.Split('~');<br />
int time = Convert.ToInt32(get_Split[1]);<br />
if (get.Contains("rshutdown"))<br />
{<br />
System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString());<br />
}<br />
}<br />
if (get == "rWord")<br />
System.Diagnostics.Process.Start("winword");<br />
if (get == "rExcel")<br />
System.Diagnostics.Process.Start("excel");
Why is that so that only the one command work?
|
|
|
|
|
PC17 wrote: It´s difficut to explain it!
I can't imagine why it would be difficult. Just give us the facts, with all the relevant details, and you'll get an answer. Read my sig.
Here are just a few of the unclear points:
- are client and server on the same machine? if not:
- where is winword or excel to run? how is the client involved?
- which machine should shutdown? the server? can any client tell the server to shutdown?
And you should publish code inside PRE tags, that way you would have seen yourself that at least one of your code snippets will not even compile. Read my sig.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Aha! Now I understand. The problem is with these lines
string[] get_Split = get.Split('~');
int time = Convert.ToInt32(get_Split[1]);
Take the example of starting word. get is "rWord" get_Split will have length 1
ie:
get_Split[0] = "rWord"
the line
int time = Convert.ToInt32(get_Split[1]);
tries to access an array element that doesn't exist get_Split[1] , this will throw an error.
This will work
if (get == "rWord")
System.Diagnostics.Process.Start("winword");
if (get == "rExcel")
System.Diagnostics.Process.Start("excel");
if (get.Contains("rshutdown"))
{
string[] get_Split = get.Split('~');
int time = Convert.ToInt32(get_Split[1]);
System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString());
}
|
|
|
|
|
The two pieces of code aren't actually the same. You haven't just moved the string[] array, you've also moved the second } . Try this to see if it has any effect:
string[] get_Split = get.Split('~');
int time = Convert.ToInt32(get_Split[1]);
if (get.Contains("rshutdown"))
{
System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString());
}
if (get == "rWord")
System.Diagnostics.Process.Start("winword");
if (get == "rExcel")
System.Diagnostics.Process.Start("excel");
}
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
@keefb
Thank you, you have understand my problem!
now i can open Word and so when i put the code on the Front place!
But now this code doesn´t work!
if (get == "rshutdown_without_warning")
System.Diagnostics.Process.Start("shutdown", "-s -t 0");
if (get == "rshutdown_abort")
System.Diagnostics.Process.Start("shutdown", "-a");
thank you at all!!!
EDIT:
I don´t know why but it works!
Thank you at everybody, it´s a very good forum, there are a lot of very clever people!
modified on Thursday, August 20, 2009 4:22 PM
|
|
|
|
|
hi everyone.
i am looking for some help with my project.
i have x and y position and a string. i want to write that string in a text document at that x and y position.
can anyone pls help me
|
|
|
|
|
Does x and y represent a character index and a row index?
If you want to edit a text document then you need to read it, edit it, and write it to another file (temp) and then rename that file (with a File.Move) - unless you want to read all the file into memory then write it straight back to the original file, depends on file size really but I would avoid either way.
So you could use a System.IO.StreamReader to read the file a line at a time and write each one to temp file. Then when you get to the line you want to edit, add the data at the required position and write that line ti temp file. Then write remaining lines.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Here is one method:
1. Open a StreamReader
2. Open a StreamWriter to the new file
3. Do a ReadLine on the StreamReader y times, writing the result to the StreamWriter using WriteLine
4. On the Stream Reader Do a ReadBlock(x) and call Write on the StreamWriter, passing in the result.
5. Write the text to be inserted
6. Call StreamReader.ReadToEnd() and write the results to file using the Writer.
There are a couple of things to look out for:
a) The algorith I have given you writes to the correct position. There could be out-by-one errors (e.g. writing to a character or line before of after the one desired) as I haven't tested it.
b) You'll get exceptions if y is greater than the length of the file. Similarly, if x is greater than the length of line y, an exception will be thrown
Take a look at http://msdn.microsoft.com/en-us/library/system.io.filestream.aspx[^], the "HowTos" at the bottom contain "How to Read from File" and "How to Write to File" links which will be useful.
|
|
|
|
|
thank u.....
actually i have to create a new file and write the text at a particular X and y position.
how do i do that?
i have the position X and Y in pixels.
|
|
|
|
|
That's even easier. Open the StreamWriter and loop around y times calling WriteLine("") each time.
Next loop around x times calling Write(' ') assuming you want to use space as your padding character.
Call Write again, passing in the text you want to insert.
Again, you'll need to check the output file to esure the method I have given you is correct as I haven't checked it and it might all be out by one line and/or character.
|
|
|
|
|
|
That doesn't make any sense. Text holds characters and doesn't know about fonts and sizes, so pixels don't exist in the world of text.
Formatted text (such as a Word document, a Wordpad document, an HTML document) knows about formatting, but strictly speaking still does not know about exact pixel location.
If it is formatted text you're after, first thing to decide is which format to use.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
luc i am sorry i am not able to understand u... can u pls explain me more
|
|
|
|
|
You'd confused your terminology. Pixels are the small dots that make up the screen display, normally associated with screen resolutions and graphins files.
e.g. a screen might show 1024 x 768 pixels, a bitmap is 100 pixel x 100 pixels etc
You used "Pixel" where you meant a character position (I think!)
|
|
|
|
|
i have x and y in pixels only.
i get that x and y from a xml. this xml is generated from a web application which contains many dynamically created 'div's. user will be able be move these div s around. on clicking save i store their pixel positions as attribute in xml.
now i need to write the value associated with each div s( which are again saved as an attribute) in their corresponding positions( ie x and y position)....
can anyone help me... pls
modified on Thursday, August 20, 2009 7:43 AM
|
|
|
|
|
You could use the Graphics.DrawString method which will take either a System.Drawing.Point or x and y coordinates in pixels. Just look up DrawString on MSDN for documentation.
modified on Thursday, August 20, 2009 5:08 PM
|
|
|
|
|
ya i already looked it up. but it doesnt write to file right? or does it?
|
|
|
|
|
No, it won't write to a text file. Like it was already said, text files aren't measured in pixels. If you have to save it to a file, the only way would be to save it in some image format. I suppose if you knew your printers resolution (dots per inch, etc..) you could print to a certain x,y location on the page, but as far as a text doc goes, there just aren't any measurements in pixels, so I don't believe it is possible to do exactly what you are wanting to do.
|
|
|
|
|
When im chagning the cell in datagrid and im still standing on the same cell if i press the "Save" button it's not been update. (Just the cell that im still standing on).
What is the best and quick way to update the cell that been change before continue and save the data ?
|
|
|
|
|
check whether save button saves the records in the database... If it is not updated in the database then check your insert query... If the records are saved in the database then rebind the grid again so that the database updates will reflect in your page....
|
|
|
|
|
Hi,
This is my linq query, I wanted this query to dynamilcally fetch the fields mentioned after select{----------------------};
var res1 = from tbltrans in ctx.tblTransferDatas
join tblemp in ctx.tblEmployees on tbltrans.EmployeeID equals tblemp.EmployeeID
join tbldpt in ctx.tblDepts on tblemp.DeptID equals tbldpt.DeptID
join tbldiv in ctx.tblDivisions on tbldpt.DivisionID equals tbldiv.DivisionID
join tblreg in ctx.tblRegions on tbldiv.RegionID equals tblreg.RegionID
join sites in ctx.tblSites on tbltrans.Site_No equals sites.Site_No
join ters in ctx.tblTerminals on tbltrans.Ter_No equals ters.TerNo
select new
{
tbltrans.TransferData_ID,
tbltrans.ActionDate,
tbltrans.CardSnr,
tbltrans.Updated_to_Card_By_CP,
tbltrans.Updated_to_Card_By_Ter,
tbltrans.Deleted_By_CP,
tbltrans.SiteTer_Type,
tbltrans.Site_No,
tbltrans.Ter_No,
tblemp.BadgeNo,
tblemp.FullName
,
tbldpt.DeptID,
Dept = tblreg.RegionName + "/" + tbldiv.DivisionName + "/" + tbldpt.DeptName,
sites.Site_Name,
ters.Terminal_Name
};
How to write and add predicates to the main query.
I wanted to add a dynamic predicate before select,I would appreciate any early replies.
Many thanks in advance.
regards
Sajid
|
|
|
|
|
Hi,
If i have Event in some class the contain a lot of function from its kink and i want each instance to check another term how can i get delegate to non static Methods?
In the code the problem is in this line because the function need to be static but i need it to operate with the data inside of the instance:
VFC.ValidSystemFunction += (ValidSystem)Delegate.CreateDelegate(typeof(ValidSystem), mi);
(mi i MethodInfo the point to non static method).
for example :
public class ValidationFunctionClass
{
public int Id;
public string Name;
public bool Checked;
public double Min;
public double Max;
public ValidSystem ValidSystemFunction;
#region List of condition functions
public bool Nc(DuplexTSystem DTS)
{
return DTS.Nc>= Min && DTS.Nc <= Max;
}
public bool qr(DuplexTSystem DTS)
{
return DTS.qr >= Min && DTS.qr<= Max;
}
....
}
And i want to have a list with all the condtions :
other class:
class B
{
public void InsertDataToList()
{
List<ValidationFunctionClass> m_ValidadtionFuncClass = new List<ValidationFunctionClass>();
System.Reflection.MethodInfo[] mi_Arr = typeof(ValidationFunctionClass).GetMethods();
int ind=0;
foreach (MethodInfo mi in mi_Arr)
{
ind++;
ValidationFunctionClass VFC = new ValidationFunctionClass();
VFC.Id = ind;
VFC.Name = mi.Name;
VFC.Checked = true;
VFC.Min = 0;
VFC.Max = 100;
VFC.ValidSystemFunction += (ValidSystem)Delegate.CreateDelegate(typeof(ValidSystem), mi);
m_ValidadtionFuncClass.Add(VFC);
}
}
}
Can some when tell me what can i do this row VFC.ValidSystemFunction += (ValidSystem)Delegate.CreateDelegate(typeof(ValidSystem), mi);
when the function is not static ? (Instance)
Thanks for all your help... I need it...
|
|
|
|
|
I Found the Solution, it's very simple,
you neet to send the instance to the CreatreDelegate.
in my case :
VFC.ValidSystemFunction += (ValidSystem)Delegate.CreateDelegate(typeof(ValidSystem),VFC, mi);
|
|
|
|
|
Hi,
I need to write a c# program which tracks the changes in excel spreadsheet cells, without saving the file in hard disk.
Without using excel functions, need to detect the changes.
Please guide me to achieve this functionality.
Thanks in advance.
|
|
|
|
|
NarVish wrote:
I need to write a c# program which tracks the changes in excel spreadsheet cells, without saving the file in hard disk.
Without using excel functions, need to detect the changes.
Please guide me to achieve this functionality.
Hello,
Have you read point #2 in the guidelines[^]? It says:
Be specific! Don't ask "can someone send me the code to create an application that does 'X'?". Pinpoint exactly what it is you need help with.
Have you read up on Excel automation? What are the steps that you've taken so far to achieve this functionality?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|