DdoubleD 315 Posting Shark

True. However, note the keyword "unsafe" and take heed. Since you already come from a C/C++ background, I would suggest writing any necessary pointer manipulations in that language and keeping your C# code clean of such practices because .NET allows you easily mix languages. Also, consider that the C# environment does not support address level debugging, which is another good reason to preserve good managed code.

DdoubleD 315 Posting Shark

Syntax in C# is very similar to C/C++, so the transition will be very easy and the compiler errors should look familiar.

You will no longer be able to manipulate pointers like you could in C++, which is a selling point to corporations, but a slight to major inconvenience at first to learning C# coming from a C background. Also, you will no longer be able to set "data" breakpoints because of this feature.

Functions become methods in C#, and you cannot assign values to arguments in the prototype/signature of the method. Although, I read a few months back that they were going to add this feature to the C# language in the next release.

Inheritence: you can only inherit a single base "class" in C#, which is a different way of thinking after developing in C++. C# makes heavy use of "interface" objects.

DdoubleD 315 Posting Shark

Here are some considerations if you intend to market your skills with prospective employers:
- find out what the employers in your area are developing
- check out freelance development sites to see what kinds of consulting contracts are in high demand
- do the same with job posting websites

Other considerations:
- import/export data to existing popular applications
- design/refine your objects so the functionality can be plugged into multiple interfaces with ease

Regards,
David

DdoubleD 315 Posting Shark

You are trying to pass a "List<B>" type to your method when it is defined as accepting argument "List<A>". If class B contains a List of A's, you could define:

public class A {}
    public class B : List<A>
    {
       
        void doAStuff(List<A> someAs)
        { // do stuff }

        List<B> b = new List<B>();
        doAStuff(b[0]); // compiles
     }
DdoubleD 315 Posting Shark

Icon class is there.

System.Drawing.Icon c = new Icon(@"c:\app\mapp\p1.ico");
pictureBox1.Image = c.ToBitmap();

I tried that--it did work. What I can't figure out is how to convert my Stream containing the icon (bitmap). I saved that icon to a file from the stream in order to narrow down the problem.

I don't understand why the Bitmap object initialization works from the file OK in this case, but not from my stream:

MemoryStream ms = new MemoryStream(webClient.DownloadData(uriIcon));
            Bitmap bmp = new Bitmap(ms); // throws exception

But, if I save the memorystream above to a file, then read it with the code you gave, it works (no exception thrown).

This failure (ParameterInvalid exception) only occurs with certain icons I test, which is why I provided the sample. How can I convert this icon directly from my stream to a bitmap without having to save it to a file first?

Thanks,
David

DdoubleD 315 Posting Shark

Do not create duplicate thread for the same question.

Sorry, it won't happen again. I would have deleted this one if I could have. I just thought if I narrowed down the title/topic it might be easier found by someone knowledgeable with the Image class.

DdoubleD 315 Posting Shark
private void frmAddress_Load(object sender, System.EventArgs e)
        {
            String[] firstName = { "Julie", "Tony", "Frederick", "Betty", "Paul", "David", "Heather" };
            String[] lastName = { "Ostendoft", "Bush", "Slater", "Gardner", "Rivers", "Lee", "Small" };
            String[] address = { "123 Fort St.", "456 Comp St.", "789 Blue Ave", "3452 Missouri Rd.", "43418 Old River Rd.", "457 Addy Ct.", "4233 Harvey St." };
            String[] city = { "Baltimore", "Dallas", "Fort Worth", "Owings Mills", "Miami", "Colorado Springs", "Los Angeles" };
            String[] state = { "Maryland", "Texas", "Texas", "Maryland", "Florida", "Colorado", "California" };
            String[] zipCode = { "21234", "12345", "67890", "32345", "43418", "31241", "31489", "83974" };

            StreamReader iFile = new StreamReader("Address.txt");
            StreamWriter oFile = new StreamWriter("Address2.txt");
            for (int i = 0; i < lastName.Length; i++)

                oFile.Write(String.Format((lastName[i] + "," + lastName[i] + "\n" + address[i] + "\n" +
                    city[i] + "\n" + state[i] + "\n" + zipCode[i])));
            oFile.Close();
            oFile.Close();
        }


1) You are never reading from your input file--you have hard coded the information.
2) You are writing your lastname field twice
3) You are closing your output file twice, but never you input file.

Regarding you other question about whether you should have a delimiter after every line: not necessary because the EOL <CR/LF> is your delimiter separating the fields as far as I can tell.

DdoubleD 315 Posting Shark

It seems this method doesn't support ico file. I tried with .bmp files, its working fine.

Are you sure this method doesn't support ico files? I haven't seen that claim anywhere until now. Sure would be helpful to know for sure.

DdoubleD 315 Posting Shark

You would think that MS would have added all of this Parsing to Volume/Path/Filename class by now, but I guess they don't want to piss off some of their partner's value added resales of libraries or something. Anyway, I would resort to searching existing code available at CodeProject or something. This stuff is like reinventing the wheel many times over in its fundamental IO statistics/demographics/structure.
Anyway, here is what I got from a relative path for your volume info request using "..\*.*":

Console.WriteLine(Directory.GetDirectoryRoot(args[0])); // returns volume as "C:\"

good luck.

DdoubleD 315 Posting Shark
for (int i = 0; i <= rowID-1; i++)
{
    for (int j = 0; j <= columnID-1; j++)
    {
         if (c[i,j].Equals(myFormsTextBox))
             ;//do something
     }
}
DdoubleD 315 Posting Shark

Use StreamWriter.

WAIT!!! Are you trying to read or write? -- LOL

DdoubleD 315 Posting Shark

Use StreamWriter.

DdoubleD 315 Posting Shark

OK. You are in over your head on this I think. So, let's take this a step at a time and see if you can accelerate your understanding of compiler errors and how to reference/interpret the meaning:

Error 4 No overload for method 'Add' takes '0' arguments

private void btnAdd_Click(object sender, System.EventArgs e)
        {
            this.lstBoxDisplay.Items.Add();
        }

This is telling you that the Add() method you are calling requires parameter(s). In other words, you need to give it something to add:

private void btnAdd_Click(object sender, System.EventArgs e)
        {
            string apples = "apples";
            string oranges = "oranges";
            this.lstBoxDisplay.Items.Add(apples);
            this.lstBoxDisplay.Items.Add(oranges);
        }

Above will add two items: apples and oranges.

Given you are working with a contact list, you items will be different. Also, they don't have to be strings. However, to display properly in your list box, the ToString() method will need to return the appropriate string representation--done automatically above because apples and oranges are both declared string objects.

Here is the best part: If you are using Visual Studio, you can right click on a method (like Add()), and select go to definition, which will tell you how the method expects to be called. Also, if you press F1 while in the Error list, hopefully (doesn't always work), it will take you to the help for this error.

I feel you might be in over your head on this. Play around with the environment given this information and become more comfortable in understanding the tools you …

DdoubleD 315 Posting Shark
DdoubleD 315 Posting Shark

Oh... where to start... Since you do nothing in the Load event, I assume you press a button or something that causes your first noticeable error? Regardless, let's start with your first noticeable error--where does this happen?

DdoubleD 315 Posting Shark

This file looks OK to me. I have permissions. See attached icon file (894 bytes long).

DdoubleD 315 Posting Shark

Here it is:

string path = Path.GetDirectoryName(args[0]);
            string filespec = Path.GetFileName(args[0]);

            Console.WriteLine("Path: " + path);
            Console.WriteLine("Filespec: " + filespec);
            Console.Read();

Tested with "C:\*.*" on command line.
I assume you know how to check args and substitute current directory with *.* if the user does not supply args?

DdoubleD 315 Posting Shark

1) The problems I have with this solution, however, is that it feels strange to have to add the space between the path and the filename.. I'm sure there is some method out there to parse out the information if a single string is given.

2) Also, this would not work if args[] has a 0 length, because the args[0] would be at best null, or "", and either one would cause the program to fail. I've tested this by using both DirectoryInfo currentDir = new DirectoryInfo(); and DirectoryInfo currentDir = new DirectoryInfo(""); .

3) Also... args[0] may not be the specific location of my path in every case. I eventually want to be able to parse other parameters out of the string. But that is another issue to be dealt with.

1) It appeared you wanted to utilize two params--sorry. You are correct that you can parse the filename out of the path.
2) True--that's why I told you to not exceed Length...
3) too many unknowns...

I will attempt to help you with your parse in item 1, to utilize only one parameter in args. BRB

DdoubleD 315 Posting Shark

Do you know the textbox's on the form that appear so you can search your array of TextBox controls (c[,]), or are you needing to enumerate through all controls on the form for textboxes first?

DdoubleD 315 Posting Shark

Not clear. Please give the source...

DdoubleD 315 Posting Shark

In that , if i enter words without spaces like"tenthousand" or "minus ten thousand" , its giving zero......
i want that in first case it should give message as"enter words with proper spacing" and in second case it should give "-10000".....

What can i do for this

I am fresh out of tea leaves, but here is a couple of suggestions:
1) instead of trying to determine the user left out a space, just report the string that could not be understood and give them a list of reasons why it might have happened:
...possibly because:
- missing space between words
- ...(another reason),
- etc.
...proper usage is: "..." -- tell the user how to use it and give good examples, and, perhaps, some invalid entries for examples of what not to input.
2) If you are able to translate 10000, then you can probably figure out that you just need to add "minus" to your search/hash table if you really want to allow the usage of the word "minus" for -10000; otherwise, resort to suggestion 1 as a catchall--recommended.

DdoubleD 315 Posting Shark

Just a guess because it's a common error: are you checking for "\\" (double backslash) when checking for the backslash char in your string (e.g. "Maps\\Download\\..."? Backslash is an escape code and you need two of them to translate literal.

DdoubleD 315 Posting Shark

No problem--glad it worked for you. Please mark this thread as resolved.

DdoubleD 315 Posting Shark

LOL... I think you might be asking multiple questions here, so let's start with the first:

okay, basically i want a completely different and random range of numbers everytime i make a Random instance.

Here is an answer:

// Ensure our numbers are indeed random
            // Passing in the Millisecond is known as "seeding"; without seeding, each instance would probably produce the same result
            Random hit1 = new Random(DateTime.Now.Millisecond);
            System.Threading.Thread.Sleep(5);// 5 milliseconds just in case
            Random hit2 = new Random(DateTime.Now.Millisecond);

            // both of these will produce two different random numbers in range 50 - 99
            int num1 = hit1.Next(50, 100);
            int num2 = hit2.Next(50, 100);

Now, is there another question?

DdoubleD 315 Posting Shark

Here is the code you posted with the changes. I just tested it passing in "c:\ *.*" and it worked find--again, note the space between the arguments. You will want to ensure you don't access "args" outside it's Length, or you will get an exception.

static void Main(string[] args)
        {
            foreach (string s in args)
                Console.WriteLine("arg: " + s);
            Console.Read();

            DirectoryInfo currentDir = new DirectoryInfo(args[0]);// (Environment.CurrentDirectory);

            DirectoryInfo[] dirList = currentDir.GetDirectories();
            FileInfo[] fileList = currentDir.GetFiles(args[1]);//();

            foreach (DirectoryInfo dir in dirList)
                Console.WriteLine("Directory: {0}", dir);
            foreach (FileInfo file in fileList)
                Console.WriteLine("File: {0}", file);
        }
DdoubleD 315 Posting Shark

Second part, with filename search spec:

FileInfo[] fileList = currentDir.GetFiles(args[1]);//();

I tested this using "app.exe ..\..\ *.csproj". Note the space between "..\..\" and "*.csproj".

DdoubleD 315 Posting Shark

Here is an example of a feed from the command line. I tested with "app.exe ..\..\" from the command line and it worked:

DirectoryInfo currentDir = new DirectoryInfo(args[0]);// (Environment.CurrentDirectory);
DdoubleD 315 Posting Shark

Gah: I'm having trouble following this thread. Based on the original code you submitted, what is the line of code you want to modify and from what?

You can leave out all the "game" details and just tell me the number(s) you need and show me the line(s) please (just the logic in other words).

DdoubleD 315 Posting Shark

Online pages from Data.Binding.with.Windows.Forms.2.0 http://dotnet-forms.info/Addison.Wesley-Data.Binding.with.Windows.Forms.2.0-Programming.Smart.Client.Data.Applications.with..NET/032126892X/ch05lev1sec11.html
and The Lightning Framework for Smart Client

After looking into the second link you sent some more, I found control types already available for my field object, one of them being the LinkLabel I wanted. I sort of got tunnel vision with the first link, and didn't peruse the second link deep enough. I don't know why I couldn't see these other controls available before, but it was reading deeper into that second link's document that I decided to give it some more time. Anyway, thanks adatapost! I'll mark this resolved as soon as I figure out how--:)

DdoubleD 315 Posting Shark

Reposting method: I don't know why the tags didn't display the code properly. If this fixes your problem, please flag as Solved--thanx.

public static TreeNode FindTreeNodeText(TreeNodeCollection nodes, string findText)
        {
            TreeNode foundNode = null;
            for (int i = 0; i < nodes.Count && foundNode == null; i++)
            {
                if (nodes[i].Text == findText)
                {
                    foundNode = nodes[i];
                    break;
                }
                if (nodes[i].Nodes.Count > 0)
                    foundNode = FindTreeNodeText(nodes[i].Nodes, findText);
            }
            return foundNode;
        }
DdoubleD 315 Posting Shark

Hai,
@DangerDev
I get a input from the user and based on this input there will be corresponding node in my tree view(Can be at any level inside the treeview),and I will know only its name .Have to find this node and append my child node to it..
Where I add my child Node depends on the user and has to be done at runtime..
Hope this Helps..

If you are searching on the TreeNode text, you can use the following recursion:

    public static TreeNode FindTreeNodeText(TreeNodeCollection nodes, string findText)
    {
        TreeNode foundNode = null;
        for (int i = 0; i < nodes.Count && foundNode == null; i++)
        {
            if (nodes[i].Text == findText)
            {
                foundNode = nodes[i];
                break;
            }
            if (nodes[i].Nodes.Count > 0)
                foundNode = FindTreeNodeText(nodes[i].Nodes, findText);
        }
        return foundNode;
    }

The node collection is the TreeView's Nodes (tv.Nodes). If found, you simply foundNode.Add(new TreeNode());

DdoubleD 315 Posting Shark

Hai,
Thanks for the Quick response..
If I do TreeView's TreeNodeCollection Find method it will return me a treenodecollection and any changes I do will not be reflected in the actula treeview.Please correct me if I am wrong..

It will return a reference to the node collection, so your changes will apply.

DdoubleD 315 Posting Shark

When I try:

Image img = Image.FromFile(fileName);

I get a SystemException: "Out of Memory".

Admittedly, I don't know much concerning graphics. Can anybody tell me why this icon throws an exception? I have included it for examination.

DdoubleD 315 Posting Shark

If you are not actually using the TreeNode.Name (was unclear), you will need to use recursion on the TreeNode.Text. Let me know if you need help with that.

DdoubleD 315 Posting Shark

Hello,

I have a treeview control and want to add a node to it at a desired location or as the child of a Certain Node X.The problem is I will know nodename[or the Text displayed ] of X only at runtime.

How do I Iterate the tree to find the given Node and add a child to it ??

Do I have to write a recursive function that iterates the nodes of a tree,find the given node and add a child to it OR is there an easier way to do this..

Use the TreeView's TreeNodeCollection Find method:
public TreeNode[] Find(string key, bool searchAllChildren);

Then, peruse the returned array for your specific node and Add your new node.

DdoubleD 315 Posting Shark

i could not understand the logic ,then how can i start............

Start by providing a portion of code logic that you don't understand and we will try to explain so you will understand it.

DdoubleD 315 Posting Shark

Thanks agent154!

DdoubleD 315 Posting Shark

OK, I think I managed to solve it on my own through reading some examples online, and finding a table of "magic numbers"

Care to share your "magic" find with the community?

DdoubleD 315 Posting Shark

My effort to retrieve favicon.ico sometimes fails even though it is found. It fails when attempting to convert the stream into a BMP or an Image using FromStream(), with the ArgumentException, or Parameter Invalid. I've tried all kinds of things to manipulate this and I guess I don't know what I'm doing.

When I save the stream to a file (SaveStreamAsIconFile) as *.ico, it appears to be a valid icon (explorer displays it, and the IDE even shows it).

Here is a link that won't work, and also the code I am using to download and convert the stream:

www.Juniper.com

public static Image GetFavIcon (Uri uriIcon)
        {
            WebClient webClient = new WebClient();
            
            MemoryStream ms = new MemoryStream(webClient.DownloadData(uriIcon));

            MiscMethods.SaveStreamAsIconFile(ms, uriIcon.Host);
            
            ms.Position = 0;
            
            Bitmap bmp = new Bitmap(ms);

            return bmp;//Image.FromStream(ms);
        }
DdoubleD 315 Posting Shark

Hi!!!!
Example we enter "One crore twenty lakh thirty four thousand seven hundred eighty four" ,
then its corresponding numeral should be "12034784".

This looks familiar. See: http://www.daniweb.com/forums/thread209656.html

DdoubleD 315 Posting Shark

I cannot find any way to tie my existing DataSource object into the DataSet I created. So, I tried recreating my object table by adding data columns to the DataSet, but I can't figure out a way to bind a LinkLabel control to the data column. So, I'm back where I started.

Maybe there is no way to do what I am trying to do?

DdoubleD 315 Posting Shark

Do you have a typed dataset in your project? Add -- New -- dataset?

I did not. I will play with that and see what happens--thanks.

DdoubleD 315 Posting Shark

The .xsc file belongs to your DataSet and not the individual DataSource, i.e. you can have 1 DataSet but 30 DataSources that reference the single typed DataSet.

But, shouldn't I have an .xsc file generated somewhere? I've searched my entire project folder (all of solution) and I don't have one.

DdoubleD 315 Posting Shark

Online pages from Data.Binding.with.Windows.Forms.2.0 http://dotnet-forms.info/Addison.Wesley-Data.Binding.with.Windows.Forms.2.0-Programming.Smart.Client.Data.Applications.with..NET/032126892X/ch05lev1sec11.html
and The Lightning Framework for Smart Client

I looked into these documents, which refer .xsc files generated by the wizard, but I don't have any of these files. Only the top level file is generated (e.g. TestDataSource.DataSource). The reference indicates that "if the data source is a typed data set definition," then I should see these .xsc files, but I cannot find information related to ensuring my data set definition is "typed" per say.

I believe there might be some information I could provide above my property inside of square brackets (e.g. [COLUMN=...] or something), but I don't know where to find information on manually using these definitions either. I don't know if that is what it is expecting either though.

Any more thoughts?

DdoubleD 315 Posting Shark

Did you check to see if the report design (.rpt file) is using the option to "save data with report?" The reason I ask is because when this option is used it might be also maintaining the original path to the DB connection; and even though you are supplying an alternate path in your connection string, the report might be trying to validate the path to the data stored with the report. Does this make sense?

DdoubleD 315 Posting Shark

I started browsing the first document, which seems enlightening. I will continue looking into this tomorrow because I'm too tired to play with it right now. Thanks!

DdoubleD 315 Posting Shark

thanks 4 ur rply, but
i m making a window application not web application.
there is no connection to the web.
plz tell me answer with respect to a window application....

So, not in a web browser, but a file parser? And if I read your other post correctly, you want to parse .NET Forms? For what exactly?

DdoubleD 315 Posting Shark

>When the DataSource object is created via the wizard, it will create a TextBox for "Field1", .
Which application are you talking about - web or desktop?

desktop application

DdoubleD 315 Posting Shark

Yes, correct. Another way you could do it is to:

Main main = new Main();
//set value here
if (main.User = "Admin")
    main.btnAdmin.Enabled = true;
else
    main.btnAdmin.Enabled = false;
main.Show();

You would of course need to make the button public to do it this way, and I don't suggest it, just pointing out yet another fix.

DdoubleD 315 Posting Shark

Ok, I understand. I thought I was setting the variable before the Main() constructor occurred. If I move the code that sets the variable inside the Main() constructor, before the IF statement, will that work?

Thanks.

No, you cannot just move code inside the Main() constructor; unless, you pass in the user var into the Main constructor: e.g. Main(string user), which will allow the "if" block to see the current value. Does that make sense?