|
well I couldn't find a command called getfromdatabase.
Did you mean I would have to create my own subroutine and storage variable?
I did that for a checkbox, so now when the checkbox is changed a static boolean variable is swithced. That works for checkboxes, but implementing it for textboxes for instance might prove cumbersome.
|
|
|
|
|
No, all I did was asuming. I asumed you would get data from a 'place' and that 'place' would be getFromDatabase().
But to recap, to clear that I understand your problem well:
You have a form which you create and can own
You have a process running on a computer
This process will change some stuff and you want to get those on your form for debugging.
To refresh, you are using a checkbox with an OnChanged event?
But when you click on the checkbox, nothing happens.
Is this correct?
If it is, please send the code which is inside the OnChanged event. Then I can maybe see the problem.
If there is no code inside this event, then I would suggest you to call a function which will place the values you would like to see/debug, on your screen.
|
|
|
|
|
i have problem when use axwinsock in c#
when call load winsock in vb6
what equal to this in c#
If Index = 0 Then
anzVerbindung = anzVerbindung + 1
Load Winsck(anzVerbindung)
With Winsck(anzVerbindung)
.LocalPort = 0
.Accept requestID
End With
End If
how to convert this code to c#
|
|
|
|
|
Why don't you use System.Net.Sockets?
Regards,
Rob Philpott.
|
|
|
|
|
Rewrite the code using System.Net.Sockets. You do not want to use the old WinSock control.
|
|
|
|
|
how can I put in process simultaneously all the txt files in folder?Also I want to save a different folder the same name all the txt files.
please can you show on the code?
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
class MainClass
{
public static void Main(string[] args)
{
string inFile, filePath;
string line;
DirectoryInfo di = new DirectoryInfo(@"D:\a\");
FileInfo[] files = di.GetFiles("*.txt");
Console.WriteLine("Input file name to open!");
Console.WriteLine("Sample: d:\\filename.txt");
inFile = Convert.ToString(Console.ReadLine());
StreamReader sr = File.OpenText(inFile);
line = sr.ReadLine();
foreach (FileInfo fi in files)
{
inFile = fi.FullName;
Console.WriteLine();
Console.WriteLine("Successful file open!...");
Console.WriteLine();
Console.WriteLine("Input file name to save!");
Console.WriteLine("sample: d:\\filename.txt");
filePath = Console.ReadLine();
FileStream file = new FileStream(filePath, FileMode.Create);
StreamWriter sw = new StreamWriter(file);
List<string> lines = new List<string>();
while ((line = sr.ReadLine()) != null)
{
lines.Add(line);
}
try
{
int numberOne = Int32.Parse(lines[0]);
int numberTwo = Int32.Parse(lines[1]);
int numberThree = Int32.Parse(lines[2]);
int x = numberOne + numberTwo + numberThree;
sw.WriteLine(x);
}
catch { }
sw.Close();
sr.Close();
}
}
}
</string></string>
|
|
|
|
|
USE A LOOP AND STOP ASKING TWICE IN 2 DAYS, YOU ALREADY GOT HELP. FUCK BOLD TEXT IS ANNOYING, ISN'T IT!!!!!!!!!!!!!
|
|
|
|
|
|
this is your original thread[^]. Notice the missing posts? Those are yours. Way to delete them, that way if someone comes and actually searches the forums for a problem similar to yours, they won't find it. Because you're an asshat.
Secondly, read this[^] now that you've posted more then 5 times, you still don't follow those rules and if you post more then 5 time's, you really should be able to by now.
You received an answer in your previous thread, do not ask again until you try something new and get stuck there, you have not rendered any additional code or attempted a new method to accomplish your task, so the old answers still stick.
|
|
|
|
|
you are right.
Excuse me
|
|
|
|
|
NO! STUPID F* WHO CAN'T THINK ARE ANNOYING!
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
problem solved.
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
class MainClass
{
public static void Main(string[] args)
{
string inFile;
string line;
const string inDir = "D:\\data\\A\\";
const string outDir = "D:\\data\\B\\";
DirectoryInfo di = new DirectoryInfo(inDir);
FileInfo[] files = di.GetFiles("*.txt");
foreach (FileInfo fi in files)
{
inFile = fi.FullName;
StreamReader sr = File.OpenText(inFile);
List<string> lines = new List<string>();
while ((line = sr.ReadLine()) != null)
{
lines.Add(line);
}
int numberOne = Int32.Parse(lines[0]);
int numberThree = Int32.Parse(lines[2]);
int x = numberOne + numberThree;
sr.Close();
string destFile = Path.Combine(outDir, fi.Name);
File.WriteAllText(destFile, Convert.ToString(x));
}
}
}
</string></string>
|
|
|
|
|
I have opened a exe file using
System.Diagnostic.Process.Start("filename");
I want to close the opened exe file..
How do i go about it
Thanks for any help in advance
|
|
|
|
|
If you don't have the process handle, use Process.GetProcesses(); to get all running processes, search for your process, and destroy by using Kill() method.
Calin
modified on Wednesday, February 18, 2009 11:46 AM
|
|
|
|
|
Here is your solution:
using System.Diagnostics;
...
Process newProc;
newProc = Process.Start("filename");
...
newProc.CloseMainWindow();
The newProc.CloseMainWindow() method is used for Window apps. For Console apps use the newProc.Kill(); method instead.
|
|
|
|
|
Hi,
I used
proc.CloseMainWindow();
for closing the exe file.
It works well, but i have opened more than one exe file.
This code does not work for that case..
|
|
|
|
|
for more then one process, you can use List<Process> procList = new List<Process>(); and you can manipulate all of the started processes individually.
List<Process> procList = new List<Process>();
...........
Process newProc;
newProc = Process.Start("filename1");
procList.Add(newProc);
newProc = Process.Start("filename2");
procList.Add(newProc);
...............
foreach (Process p i in procList)
p.CloseMainWindow();
Hope this helps!
modified on Thursday, February 19, 2009 4:44 AM
|
|
|
|
|
Hi,
It works well..
Thanks for the help
|
|
|
|
|
You welcome!
|
|
|
|
|
hi
Any idea on how to draw a line similar to the one present in ms word, the line can be rotated about 360 degrees and also it can be resizable, movable. It should be like a control with all events. Please let me know if there is any way to do this. Sending Source code is also fine with me.
any article talking about this ??????
thanx
|
|
|
|
|
You would have to create a custom control (one is not yet created like this). You would have to add events for when the ends are clicked so that it can be resized or rotated. In the drawing events you will have to draw the line based on the properties that are altered in the events (ex: angle of line, x1,y1,x2,y2,color,etc).
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
Please help me to compare the length and lines of data in 2 files which are inside a zip file.
File2:Will have details about the each file length which is inside the zip file
File1-Any file .dat file
File2-MRR_GIQ_FR_X03_M0808_STATS.dat
using System.Text;
using System.IO;
using System.IO.Compression;
namespace ConsoleApplication1
{
class Class1
{
public bool splitFile = false;
string srcFile = "C:\\SampleFile\\MRR_Files.zip";
static void Main(string[] args)
{
TestDecompress();
}
private bool FileCompare(string file1, string file2)
{
int file1byte;
int file2byte;
FileStream fs1;
FileStream fs2;
// Determine if the same file was referenced two times.
if (file1 == file2)
{
// Return true to indicate that the files are the same.
return true;
}
// Open the two files.
fs1 = new FileStream(file1, FileMode.Open);
fs2 = new FileStream(file2, FileMode.Open);
// Check the file sizes. If they are not the same, the files
// are not the same.
//if (fs1.Length != fs2.Length)
//{
// // Close the file
// fs1.Close();
// fs2.Close();
// // Return false to indicate files are different
// return false;
//}
// Read and compare a byte from each file until either a
// non-matching set of bytes is found or until the end of
// file1 is reached.
do
{
// Read one byte from each file.
file1byte = fs1.ReadByte();
file2byte = fs2.ReadByte();
}
while ((file1byte == file2byte) && (file1byte != -1));
// Close the files.
fs1.Close();
fs2.Close();
// Return the success of the comparison. "file1byte" is
// equal to "file2byte" at this point only if the files are
// the same.
return ((file1byte - file2byte) == 0);
}
|
|
|
|
|
Please use the pre tags, the code is unreadable right now.
And what exactly is your question?
|
|
|
|
|
Question:- I have one Parent domain called PDomain, and two child domains Child1, Child2. Child1 has a user called John. Child2 has a role called Developers. Now John is added as a member of group Developers.
When I try to get all roles for John, it never returns Developers.
Following is the code I am using to search:-
DirectoryEntry entry=new DirectoryEntry(Path);
DirectorySearcher mySearcher= new DirectorySearcher(entry);
mySearcher.Filter = "(&(objectClass=user) (cn=John))";
mySearcher.PropertiesToLoad.Add("memberOf");
SearchResult myresult = mySearcher.FindAll();
The issue is, Path I send as Child1, it does not have the role assigned, and if I send the path as Child2, it is not able to find the user.
I have tried using mySearcher.SearchScope = SearchScope.OneLevel; or subtree also. Nothing works.
Any idea anyone?
Nana
|
|
|
|
|
Dear all,
I am doing some screen scraping work and I am making a web request to web page that is encoded in IS0-8859-1. In order to be able to get the special characters such as the apostrope correct, I had to change the encoding of the response to windows-1252.
The following is my web request/response code:
public static string GetHTMLStringWin(string url)
{
StringBuilder html = new StringBuilder();
string htmlToRet = null;
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Timeout = 30000;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream htmlStream = response.GetResponseStream();
string temp = null;
byte[] buffer = new byte[9000];
int counter = 0;
do
{
counter = htmlStream.Read(buffer, 0, buffer.Length);
if (counter != 0)
{
temp = Encoding.GetEncoding("windows-1252").GetString(buffer, 0, counter);
html.Append(temp);
}
}
while (counter > 0);
htmlToRet = html.ToString();
}
catch
{
htmlToRet = null;
}
return htmlToRet;
}
The apostrophe is interpreted well using this method, however i am getting unwanted dashes in the text. For example the word periti is becoming pe-ri-ti. I believe that this has to be some encoding issue. The target webpage is interpreted correctly in a web browser.
Any suggestions of how may I solve this?
Many thanks,
Chris
|
|
|
|