|
Hi All,
I have a case that i need to browse through the directories and files of a unix server through C#.NET or VB.NET Code. Can anyone help me out???
Exact scenario of the problem is:
i need to ftp a file to unix server from windows machine through VB.NET Code. But Before that i need the check the unix server whether the file already exist or not in a particular directory of the unix server. If the file already exist in the unix server, i have to wait until the file to be removed in the unix server and then ftp the file to unix server.
gokulnath
|
|
|
|
|
If you know how to programmatically FTP-PUT a file, couldnt you first try an FTP-GET
to see if it already exists ?
Luc Pattyn
|
|
|
|
|
I need help... I have two datagrids, one is binded to a Datatable and one is binded to a Dataset. The problem is, keydown events are not recognized on the Datatable side while on the Dataset they work. Thanks in advance.
|
|
|
|
|
Hello
I have a question about working with COM objetcs made in C#. Creating the objetcs is not a problem, my question is how to work with config files. How do I get information from an config file so that I can read it with my COM object?
My situation right now is that I have a .Net object that most of the time will be accessed by a .Net application, but somtimes by an application written in VB6 (or any language supporting COM). In the config file for the .Net application I have some parameters that I want to read, not just in the appSettings section but also for example configSections and system.diagnoostics section.
I hope that Microsoft has thought of that when they made .Net support COM, but I dont know how they did it if they did it. Antoher solution is to always try to read the config file with ConfigurationManager.OpenExeConfiguration(FilePath) but then I cant read some sections properly without resorting to converting them into a XMLDocument:
<code
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(FilePath);
ConfigurationSection confsec = config.Sections["system.diagnostics"];
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.LoadXml(confsec.SectionInformation.GetRawXml());
System.Xml.XmlNode node = doc.SelectSingleNode("system.diagnostics/switches/add[@name='Trace']");
if (node != null)
{
System.Xml.XmlAttributeCollection attribs = node.Attributes;
TraceSwitch generalSwitch = new TraceSwitch("Trace", "Controls the Trace Level");
generalSwitch.Level = (TraceLevel)Convert.ToInt32(attribs.GetNamedItem("value").InnerText);
}
</code>
Or should I abandon config files and use INI files instead?
Is there a way in an .Net object to see if the object is started by an application using COM or if it is an .Net application?
I hope the question(s) are reasonably clear and that someone could enlighten me in the way of using config files when the calling application is an COM application written in VB6.
Sorry for my bad english.
Best regards
/Marcus
|
|
|
|
|
hi,
how to retrieve string as well as int from single function
with regards
|
|
|
|
|
Your question is not very clear :->
SkyWalker
|
|
|
|
|
satyam143 wrote: how to retrieve string as well as int from single function
The preferred method in .NET is to wrap it into a class or struct . You can also specify ref and out parameters.
class BlahResult
{
public string theString;
public int theInteger;
}
class SomeClass
{
public BlahResult SomeMethod()
{
BlahResult result = new BlahResult();
return result;
}
}
|
|
|
|
|
you can return only one value in a method.
so just return an integer and then convert to string.
|
|
|
|
|
M. A. Deniz Yalman wrote: so just return an integer and then convert to string
What if the string value he wanted was not a representation of the interger?
|
|
|
|
|
|
The easiest way is to use "output parameters".
The cleaner way might be to define a class with two parameters, then return an instance of that class from your method.
|
|
|
|
|
Discussion: Would you use static member variables in the class? Why or why not?
|
|
|
|
|
Hi,
I've got a problem with reading in an xml file into a listbox
This is the code:
XmlDocument xmlDoc = new XmlDocument();
XmlTextReader xtr = new XmlTextReader(path);
xtr.WhitespaceHandling = WhitespaceHandling.None;
xmlDoc.Load(path);
while (xtr.Read())
{
if (xtr.Name.Equals("test") && xtr.NodeType == XmlNodeType.Element)
{
this.listBox.Items.Add( xtr.ReadElementString("test").ToString());
}
Thread.Sleep(10);
}
This is the xml files content:
<?xml version="1.0" encoding="UTF-8"?>
<Testing>
<test>1111111</test>
<test>2222222</test>
<test>1111111</test>
<test>3333333</test>
<test>1111111</test>
</Testing>
The problem is, it skips the "222222" and "333333" by not adding them into the listbox.
The rest of the xml file does get loaded in the listbox.
So this is what i get:
1111111
1111111
1111111
In stead of:
1111111
2222222
1111111
3333333
1111111
Can somebody point to me what i am doing wrong?
Thanks in advance!
|
|
|
|
|
If you read the documentation for ReadElementString[^] you will see that it also moves the position in the XML file on. So for each iteration you are moving the position within the file twice.
Yustme wrote: Thread.Sleep(10);
What is this for? It serves no purpose other than to slow down your application. Is that what you really want?
|
|
|
|
|
Hi,
The sleep thread is to avoid that my pc is going to hang. There are over 2000 rows to read into the list box.
Thanks for pointing that out to me. I didn't know it moves 2 positions within the file.
|
|
|
|
|
Yustme wrote: The sleep thread is to avoid that my pc is going to hang. There are over 2000 rows to read into the list box.
That makes no sense what so ever. If you put the thread to sleep for 10 milliseconds 2000 times you are waiting 200 seconds (just over 3 minutes) to load in all the data.
|
|
|
|
|
According to the documentation the ReadElementString method positions the reader on the node following the EndElement node; in you case on the next "test" StartElement node. Afterwards you call Read inside the while statement which advances the reader to the next node and thereby your code only recognizes every second "test" element. I'm not that used to the XmlTextReader, so you have to experiment a bit which method gives you the desired result.
By the way calling ToString on the result of ReadElementString is redundant as it already returns a string.
"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." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi,
Can you tell me what method you used for these kind of operations?
Thanks in advance!
|
|
|
|
|
As said I'm not used to the XmlTextReader but after a quick glance at the documentation I would say that the ReadString method sounds quite promissing.
"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." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi,
That did the trick.
Thanks!
|
|
|
|
|
Hi Frens,
I am trying to provide the same kind of search facility which has been given in this link...
http://office.microsoft.com/en-us/default.aspx
But I am not sure how to do this....can u pls help me out..
Thanks in advance...
Vishal
|
|
|
|
|
Which bit are you looking for? The watermark? The UI? Actually searching for something?
Your post is too vague. You need to provide more information before people can answer it.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi all,
I found a code to convert a Image to byte array and back.
the image gets converted to byte array succesfully..
but when i try to convert the bytearray back to Image it gives and error saying
"Parameter is not Valid"
The code is as below:
MemoryStream ms = new MemoryStream(br); // br is the byte array
pictureBox2.Image = Image.FromStream(ms);****Error at this line...
Can anyone tell me how to solve this or some other way to it?
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
I'd expect that means your byte array doesn't contain all the information required to build an image. A byte array of pixel values is not what is needed here.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thanks for quick reply
The problem is it works for some time and then the error occurs...
i have displayed a messagebox. the messagebox is displayed 4-5 times and then the error occurs.
The main purpose of the application is i am capturing images from a camera and sending it over network.
So when i receive it back and try to convert it from a byte array to an image the error occurs.
Can u suggest any better way for this?
or what should be done if the byte array doesn't contains all the information?
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|