|
We would need to see examples of the text you are trying to parse.
|
|
|
|
|
I am having a problem for the following case:
I have an xml file in the directory of the myproject.exe file of my project. as a result i m using relative path to open the xml file.
I am openig the file using the following code:
XmlTextReader xtr = new XmlTextReader("center.xml");
I have a open file dialog box in that project and i read a MSAccess file using that open file dialog box. But after reading the MSAccess file when I try to read the xml file with the same code then exception raised and shows could not find file "path of the MSAccessfile\center.xml"
So how can I get back to the directory whre the myproject.exe file located"
|
|
|
|
|
You can get the .exe filename from :
Process.MainModule.FileName
Then get the directory from your process .exe and set the directory to OpenFileDialog.InitialDirectory.
|
|
|
|
|
I have done the following code and it solved my problem.
try
{
Process p = Process.GetCurrentProcess();
String location = p.MainModule.FileName;
int start = location.IndexOf(Process.GetCurrentProcess().ProcessName.ToString());
location = location.Remove(start);
xml = location + "center.xml";
}
|
|
|
|
|
string directoryName = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
string xml = directoryName + @"\center.xml";
|
|
|
|
|
Further to the pevious answer, using relative paths isn't a great idea. If you know for sure where a file is then use the path. The file center.xml should probably be in the runnign directory and not the application directory. Though normally the same, they can be different. The best to use is System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
I have the following code extract:
public arraylist myList = new arraylist();<br />
public struct myDBList<br />
{<br />
public string strKey;<br />
public string strName;<br />
public string strDataSetName;<br />
}
I loop thru a list of databases and add data from each to my list:
foreach (database db in dbList)<br />
{<br />
myDBList.strKey = db.Key.ToString();<br />
myDBList.strActual = db.Name.ToFriendlyString();<br />
myDBList.strDataSetName = db.Path.ToFriendlyString();<br />
myList.Add(myDBList);<br />
}
this arraylist is then passed to a 2nd form with:
Form myLogon = new Form();<br />
myLogon.passedList = myList;
In the 2nd form I have declared the same arraylist & struct and I want to loop thru the list and extract the data so I use:
ArrayList newList = new ArrayList();<br />
public struct myDBList<br />
{<br />
public string strKey;<br />
public string strName;<br />
public string strDataSetName;<br />
}<br />
string key;<br />
<br />
public arraylist passedList<br />
{<br />
get{ newList = value; }<br />
}
and in the code:
foreach( dbList db in newList)<br />
{<br />
key = db.strKey;<br />
.<br />
.<br />
}
While the code compiles, when I come to execute the foreach statement i get the error:
InvalidCastException was unhandled - specified cast is not valid
What am I doing wrong here ??
|
|
|
|
|
Just because the 2 declared structs have the same fields, it doesnt mean you can cast from one to the other.
Declare the struct once, in a project that both locations can access.
|
|
|
|
|
Thanks J4amieC.
If I'd noticed what the tags were telling me when I hovered over the foreach I'd have seen this for myself. I removed the declaration of the DBList in form 2 and qualified the DBList in the foreach with the form 1 instance and it all works !!
A case of not spotting the obvious.
|
|
|
|
|
Hi,
How to set a ID and Value to a node in tree view control. So the checked ID and Value can save in database
Thank you
YPKI
|
|
|
|
|
The TreeNode class has a Tag property that is an Object , since everything (practically) descends from Object , you can store anything there.
There is a reasonable example of doing this in the MSDN documentation for TreeNode.Tag .
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi,
How to get the child node text of all the checked child node in a tree view control?
Thankyou,
YPKI
|
|
|
|
|
check it recursively.
if(node.Checked) {stringBuilder.Append(node.Text);}
|
|
|
|
|
how can i make datagrid text box cell editable on double click so that when i double click on it it comes to edit mode.
|
|
|
|
|
To answer your question, look up the documentation for the CellDoubleClick event.
Although, why? The cell should go into edit mode when you click on it.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
i have set readonly property of textbox cell to false in cell double click event but it comes to edit mode after 3 clicks.
|
|
|
|
|
I am sure that there must be a way to put the cell into edit mode in code, but I cannot find one at the moment.
I have not tested this, but until you find a better way, you could call the RaiseClickEvent() method at the end of your DoubleClick handler.
If I find a better way, I'll get back to you.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi.
I have this console based Asynchronous VS project that works fine.
And then i have a remoting project which also works fine. I want to edit the remoting project so it is non-blocking, using asynchronous calls.
I´ve tried different examples, but I cant get it to work. None of them seems to call my callback method back.
Here is the relevant snippets:
The remote object:
....
public class MultiContainer : MarshalByRefObject, IMultiContainer
{
public string GetClientsList()
{
Thread.Sleep(1000);
return Program.ServerForm.GetClientsList();
}
....
The client which accesses the remote object with asyn call:
namespace Client
{
public partial class Form1 : Form
{
Server.IMultiContainer mc;
private delegate string Delegate();
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
mc = new Server.MultiContainer();
Delegate del = new Delegate(mc.GetClientsList);
AsyncCallback callback = new AsyncCallback(Callback);
del.BeginInvoke(callback, null);
}
private void Callback(IAsyncResult ar)
{
Delegate del = (Delegate)((AsyncResult)ar).AsyncDelegate;
richTextBox1.Text = del.EndInvoke(ar);
}
...
Been sitting with this problem for hours, hope you can help!
Thanks alot
|
|
|
|
|
I made a Server / Client ( socket Connection)
in Server Form i am having a Panel in which a Video will be played selected by the Server Admin, i want to same file should be played on 25 client machine. whatever actions done by the admin like forwarding etc. should be showen on the client . is this possible.
can we stream the video files like this. help me
thanks in advance
|
|
|
|
|
Why did I spent hours explaining to you how to do this, if you're going to just ask the same question all over again ? Why should anyone answer you, if you're not going to bother to do anything that I suggested before ?
amaankhan wrote: can we stream the video files like this. help me
As discussed, you'd be a moron to stream the actual video. You've got next to no chance of keeping things in synch that way.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Sir last time u told me to store the file on shared location.
i used that i am running on 2 client and its working fine. but how come forwarding and pausing that option .
As when server will forward the video the video on the client should also be forwards
sorry sir,
|
|
|
|
|
amaankhan wrote: As when server will forward the video the video on the client should also be forwards
I don't know what this means, but I told you to put the file on a network share, send the path to the file to each client, who could then copy it locally, and to use the network connection to send commands telling it when to play/pause/etc. There is NO way you're going to stream the file and keep it in sync.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Now *THIS* one, I remember...
|
|
|
|
|
You can. First you need to create so that there a frame capture or screen capture with a speed atleast 25 fps(This is for Europian PAL. USA uses almost 30 fps)and then send over network. Also you would need to make sure the client uses buffer for smoother streaming
|
|
|
|
|
thanks. can u give any example/sample reference link
|
|
|
|