Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
K

Karmendra Suthar

@Karmendra Suthar
About
Posts
48
Topics
16
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Last modified time in file.
    K Karmendra Suthar

    I am doing this not for cs files but my own configuration file, and it is not if user see the data but if he modifies it it will be replaced with default. i am storing a checkbox value true or false. Actually I am no good with encryption, I wasn't able to choose one to use. I actually don't want the user to modify the config file outside of my application. Can you tell me other ways to prevent it? Thanks for your words. Karmu

    C# xml tutorial

  • Last modified time in file.
    K Karmendra Suthar

    I got it, this,

    File.SetLastWriteTime(FileName,LastWriteTime);

    would do the job. Thanks.

    C# xml tutorial

  • Last modified time in file.
    K Karmendra Suthar

    Hi, I don't know from which heaven I got this idea of storing last modified time in side the XML file, as a node. But I will tell you why I need this, and can you tell me how am I suppose to do it. I want to prevent user to hack my file, they shouldn't be able to modify it and save it. If they do that, I delete that file and recreate a newer one. (Like giving monkey a banana locked inside a transparent box, he can see it but can't eat it :) ) But to accomplish this I need to store the last modified time in the file and on save do not modify the last modified time. If I am sounding crazy, let me know I will explain with an detailed example. Thanks for you Precious time, Karmendra

    C# xml tutorial

  • gif Image
    K Karmendra Suthar

    That's so much right thanks so much Luc. Observations: You always reply my questions, thanks again for that. :-D

    C# html hardware help question learning

  • gif Image
    K Karmendra Suthar

    Hi, I embedded some files in the assembly, html(text) images(gif, jpg, png). What i want to do is extract all the files to a tmp directory. I had SUCCESS in getting all the files to tmp directory. I open the text files..PERFECT. but images are not right, it says corrupt. How do I get the images extracted correctly from embedded resource and save it to disk. Following is my piece of code.

    private void button1_Click(object sender, EventArgs e)
    {
    Assembly _assembly;
    Stream _imageStream;
    StreamReader _StreamReader;

            StreamWriter \_StreamWriter;
            string dirpath = Application.StartupPath + "\\\\help";
            string\[\] resourceNames = this.GetType().Assembly.GetManifestResourceNames();
            foreach (string resourceName in resourceNames)
            {
                //get resource if it is help
                if (resourceName.Contains(".help"))
                {
                    MessageBox.Show(resourceName);
                    try
                    {
                        if (!Directory.Exists(dirpath))
                        {
                            DirectoryInfo di = Directory.CreateDirectory(dirpath);
                            di.Attributes = FileAttributes.Directory | FileAttributes.Hidden;
                            di.CreateSubdirectory("images");
                        }
                        string filename = Application.StartupPath + "\\\\help\\\\";
    
                        //if image, it should save in image folder
                        if (resourceName.Contains(".images")) filename = filename + "images\\\\";
                        //get the filename and append it to the filename
                        string\[\] filenamearray = resourceName.Split('.');
                        int length = filenamearray.Length;
                        filename = filename + filenamearray\[length - 2\] + "." + filenamearray\[length-1\];
    
                        string read = null;
    
                        \_assembly = Assembly.GetExecutingAssembly();
                        \_StreamReader = new StreamReader(\_assembly.GetManifestResourceStream(resourceName));
                        \_StreamWriter = new StreamWriter(filename);
    
                        while ((read = \_StreamReader.ReadLine()) != null)
                        {
                            \_StreamWriter.WriteLine(read);
                        }
                        \_StreamWriter.Close();
                        \_Strea
    
    C# html hardware help question learning

  • Embedded resource
    K Karmendra Suthar

    Hi, I am trying to embed html files in application. Initially, 1. I used to directly embed HTML file, I could load it using assembly manifest. But the problem with this was images were not getting loaded. 2. To deal with other problem i converted my html file and saved it as .mht format. But now it is not getting loaded. 3. Third way would be to extract the file from assembly and store it at a temp location and show in my webbrowser control. Is there a better way to do this? Please help thanks. Note: I am using Visual Studio Express 2008. Thanks, Karmendra

    C# help csharp html visual-studio hardware

  • How to call a string value from a method within another class?
    K Karmendra Suthar

    Think you need to re-visit OOPS concepts. In button click event you have created another object sm and you have set sm.abc by running testMethod. and you have never run SMSMdm.testMethod to set SMSMdm.abc, it wil give error also because you have never initialized SMSMdm.abc.

    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    SMSManager sm = new SMSManager();
    }
    public void sampleArray()
    {

        }
    
        private void button1\_Click(object sender, EventArgs e)
        {            
            sm.testMethod("82083427", "1122887779", "testmessagetxt");
        }
    }
    

    class SMSManager
    {
    public string abc="";
    public void testMethod(string MPN, string RPN, string text)
    {
    SMSModem SMSMdm = new SMSModem();

            MessageBox.Show("RPN" + RPN);
            abc = RPN;  //this isnt wrking
    
            int x = myArray.Length / 5;
           
            for (int i = 0; i < x; i++)
            {
                string a = myArray\[i, 0\];
                if (a == MPN)
                {
                    MessageBox.Show("MODEM NUMBER :"+MPN);
                    SMSModem SMSM = new SMSModem();
                    SMSM.SendSms();
                }
            }
        }
    

    class SMSModem
    {
    public bool SendSms()
    {
    try
    {
    //this is not required now
    //SMSManager MGR = new SMSManager();
    //string num = MGR.abc; //This is not retreiving the value!

                //I WANT THAT VALUE TO BE CALLED HERE AND ASSIGN IT TO "num"
    
                string num = **sm**.abc;
                MessageBox.Show("RECEIRE" +num);
         serialPort1.WriteLine("AT+CMGF=1;+CSCA=\\"+6598540020\\";+CMGS=\\"+65" + num + "\\"\\r\\n");
                System.Threading.Thread.Sleep(40);
                serialPort1.Write("Test message from coded program");
    
                char\[\] arr = new char\[1\];
    
                arr\[0\] = (char)26; //ascii value of Ctrl-Z
    
                serialPort1.Write(arr, 0, 1);
    
                System.Threading.Thread.Sleep(3000);
                string data = serialPort1.ReadExisting();
    
                MessageBox.Show(data);
    
                if (data.IndexOf("OK") != -1)
                {
                    return true;
                }
                else
    
    C# tutorial question

  • Protect password file
    K Karmendra Suthar

    And if the user deletes the xml file by going to the physical location of the file. what shall I do in such case. as of now my program recreates the xml with default password.

    C# xml help tutorial announcement

  • How to call a string value from a method within another class?
    K Karmendra Suthar

    MSManager MGR = new SMSManager();
    string num = MGR.abc; //This is not retreiving the value!
    //I WANT THAT VALUE TO BE CALLED HERE AND ASSIGN IT TO "num"
    MessageBox.Show("RECEIRE" +num);

    string num = MGR.abc; before you can do this you need to call MGR.testMethod which actually does abc = RPN; Alternatively You can set the abc in a constructor. Regards, Karmendra

    C# tutorial question

  • Protect password file
    K Karmendra Suthar

    Hi, I have created a login in my winform application, i encrypt the password and store in a xml file. I am worried about if the user deletes the xml file, he can crack into the system. can you please suggest me how to make sure user cannot delete the xml file. I tried embedding the xml file but, if i do that authorized users will not be able to change password and update the xml. Please help Thanks for your time and knowledge, Karmendra

    C# xml help tutorial announcement

  • Exception throwing - Advice required
    K Karmendra Suthar

    You can alternatively create a custom exception class using ApplicationException class[^] For more on Exception Handling Best Practices in .NET

    C# help question

  • how much is java difficult??
    K Karmendra Suthar

    Java is more like C# and C# is more like Java. They share lot of common concepts. both are pure object oriented, and if you know C# it isn't difficult to learn Java. I can recommend "Head First Java" an excellent book from o'reilly to start with Java. Sometimes Java framework like SOAP, EJB etc would scare you but once you are good with BASIC Java, Life would be much easier with them. As far as you are concerned about the databases you can use any kind of database with Sun's ODBC drivers (just google to find them). And if you are looking to make a web application, You will need to know JSP (Java server pages, 99% like Java) and Servlets. JSP is client side and Servlet is server side scripting language. I was a Java programmer, and I learnt C# with easy. Code project was always the best friend. Happy learning, Karmendra

    C# csharp question c++ java asp-net

  • [newbie] function to return MAX + 1 from primary key
    K Karmendra Suthar

    Hi,

    private System.Data.SqlTypes.SqlInt64 nextTaskRef()
    {
    try
    {
    string getTaskRef = @"SELECT MAX([taskID_PK]) FROM [teamwiki].[dbo].[task];";
    SqlCommand getTaskRefSQL = new SqlCommand(getTaskRef, conAppDB);

                object rawValue = getTaskRefSQL.ExecuteScalar();
                if (rawValue != DBNull.Value) {
                    return (System.Data.SqlTypes.SqlInt64) rawValue; **//if you return from this
                                                                        // point your finally block will not 
                                                                        // get executed, and becomes unreachable code**
                }
        }
        catch (Exception ex) {
            throw ex; **//once you throw an exception it comes out of catch block, so following code is unreachable**
            return 0; //tried to return null as well unsuccessfullly
                      //this indicates an error condition 
    
        }
        finally {
            conAppDB.Close();
        }
        **return 0; // should have return here as well, at instancecs when it reaches this point
                     // before quiting it sholud return something**
    }
    

    This code can be best written as follows

    private System.Data.SqlTypes.SqlInt64 nextTaskRef()
    {
    object rawValue;
    try
    {
    string getTaskRef = @"SELECT MAX([taskID_PK]) FROM [teamwiki].[dbo].[task];";
    SqlCommand getTaskRefSQL = new SqlCommand(getTaskRef, conAppDB);
    rawValue = getTaskRefSQL.ExecuteScalar();
    }
    catch (Exception ex) {
    throw ex;
    }
    finally {
    conAppDB.Close();
    }
    if (rawValue != DBNull.Value) {
    return (System.Data.SqlTypes.SqlInt64) rawValue;
    }
    return 0;
    }

    Happy Coding, Karmendra

    C# csharp database asp-net sql-server visual-studio

  • Loading vjslib dynamically
    K Karmendra Suthar

    Just a thought, try if you can write a small search routine and search the dll in %systemroot%\\Microsoft.NET\\ If J# runtime is installed is it definite to have the dll in C:\WINDOWS\system32\? If yes use %systemroot%\\system32\\vjslib.dll

    string path = "%systemroot%\\Microsoft.NET\\Framework\\v2.0.50727\\vjslib.dll";
    Assembly assembly = Assembly.LoadFile(path);

    regards Karmendra

    C# csharp question

  • [Message Deleted]
    K Karmendra Suthar

    Get a XmlElement and SelectSingleNode of that, instead of the XmlDocument. I am not sure why it is returning SECOND, I am beginner, I had this information thought of sharing, might help you, Let me know if it do help.

    XmlDocument doc = new XmlDocument();
    doc.Load(strFullPath);

    **XmlElement root = doc.DocumentElement;

    XmlNode bNode = root.SelectSingleNode("BIBLE");**

    string strBibleClientID = doc.DocumentElement.GetAttribute("CLIENT_ID");
    string strBibleMatterID = doc.DocumentElement.GetAttribute("MATTER_ID");
    string strBibleDocNumber = doc.DocumentElement.GetAttribute("DOCNUMBER");

    for (int i = 0; i < bNode.ChildNodes.Count; i++)
    {
    XmlNode bibleNode = bNode.ChildNodes[i];

    //number of elements per Bible...
    int intElements = bibleNode.ChildNodes.Count;

    //Go through the BIBLE node...
    for (int x = 0; x < intElements; x++)
    {
    //pull out each element...
    string strElement = bibleNode.ChildNodes[x].Name.ToString();

    if (strElement.ToLower().Trim() == "doc")
    {
    string strDocClientID = bibleNode.ChildNodes[x].Attributes["CLIENT_ID"].Value;
    string strDocMatterID = bibleNode.ChildNodes[x].Attributes["MATTER_ID"].Value;
    string strDocNumber = bibleNode.ChildNodes[x].Attributes["DOCNUMBER"].Value;
    string strDocName = bibleNode.ChildNodes[x].Attributes["DOCNAME"].Value;

    }
    }
    }

    C#

  • Cross Thread Comunication
    K Karmendra Suthar

    To learn about Threads, Synchronous and Asynchronous calls to UI Thread, using delegates and events to communicate between threads is best explained in this article. I learnt thread reading and running the demo project, Its the Best. http://www.codeproject.com/KB/cs/workerthread.aspx[^] Regards, Karmendra

    C# design tutorial question

  • Prevent un-authorised access to files.
    K Karmendra Suthar

    Hi, Thanks for all you r efforts, but i am very new .Net C#, I am not sure what you mean "embed the html", Do you mean write code that will generate the Html? Please Explain. Thanks, Karmendra

    C# html help

  • Prevent un-authorised access to files.
    K Karmendra Suthar

    :-D These help files are not related to using the software it is having information related to any experiment, and in Examination mode I do not want users to see them.

    C# html help

  • Prevent un-authorised access to files.
    K Karmendra Suthar

    Hi, I meant users should not access the files directly in the installation folder and open and view it using there internet browser. The only way for them to access those files is via my application. As you suggest embedding it, can you tell me how that can be done, sorry This might be silly to ask but I am very new to .NET and C# Thanks for you help and time Regards, Karmendra

    C# html help

  • Prevent un-authorised access to files.
    K Karmendra Suthar

    Hi, I thought of the same thing, but I was wondering how to do it, can you tell me how can I encrypt ant keep the html files and then how can I decrypt it in the application. Thanks, Karmendra

    C# html help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups