C#

91K

Solutions

24K

Contributors

C# is an object-oriented programming language created in conjunction with Microsoft’s .NET framework. Compilation is usually done into the Microsoft Intermediate Language (MSIL), which is then JIT-compiled to native code (and cached) during execution in the Common Language Runtime (CLR).

Share tech news, updates, or what's on your mind.

Sign up to Post

I am using HTTP web request,response to get the url response which is an exe from jenkins server of file size greater than 450MB. Responses are read and stored in my local drive using Filestream. When the response is continuous i could successfully download and install the exe.

Issue Scenario: At times the response read is zero and the full file is not read, so i am continuing the download by passing Webrequest.Addrange(partly downloaded size) which read bytes from the partly downloaded size and stores in my drive, after full download, i see the "cannot startup error" during installation.

I have shared the code, please guide where i am wrong. Also the server supports partial content


code i tried:
System.IO.FileStream saveFileStream = null;
 
        try
        {
            long iFileSize = 0;
            int iBufferSize = 1024;
            iBufferSize *= 1000;
            long iExistLen = 0;
            if (System.IO.File.Exists(path))
            {
                System.IO.FileInfo fINfo =
                   new System.IO.FileInfo(path);
                iExistLen = fINfo.Length;
            }
            if (iExistLen > 0)
                saveFileStream = new System.IO.FileStream(path,
                  System.IO.FileMode.Append, System.IO.FileAccess.Write,
                  System.IO.FileShare.None);
            else
                saveFileStream = new System.IO.FileStream(path,
                  System.IO.FileMode.Create,
0
Technology Partners: We Want Your Opinion!
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Using Winforms C# SQL Server

Can a dataGridView be used unbound to enter int values for calculation purposes and then insert those values into a database table after?
I need to enter package data such as Pieces, Length, Height, Width, DimFactor on either one row or multiple rows. e.g. Length * Width * Height / Dim Factor.

All the example I found refer to bound data.

Is a dataGridView the best option for this?
0
I have a function in an application that supplies  a string which is actually 3 strings with null separators.
This is rather frustrating as I could not even see the last 2 strings in the debugger.

I now need to do a string replace but this fails as the string I need to replace resides in the 2nd of the internal strings after the first null (\0).

Is there an easy way to split the string based on the null character or even better a string replace function that will work with a string constructed this way?
0
Hi experts
I have two datagridview and one button.my data has been shown in the first datagridview from sql. I want some code to do bellow but i don't know how can I write it:
When I clicking on the button,30 rows of first datagrideview choose and transfer to second one
Please help me
0
I already have model and controller that basically doing all the work I need. model is basically our domain class.
and controller is just all of combined classes that do all the thing we want like add, modify the data in xml or database.

our next is to create restful API that allow external users to use it. Do you have very simple example for us to get start it?
0
I am trying to render report to csv file, but for some reason  when I open the file in Notepad looks like columns are separated by TAB , not comma. When I open the file in Excel all columns  come as one:
208438-1      7/11/2017      9:30 AM      Eric Sherman      Eric Sherman      "300 E 56th St

This is the code:
            byte[] result = null;                  
            string historyID = null;                
            string devInfo = null;                
            string encoding;                      
            string mimeType;                        
            string extension;                      
            Reservice.Warning[] warnings = null;    
            string[] streamIDs = null;            

            _rsExec.LoadReport(rptPath, historyID);
           _rsExec.SetExecutionParameters(parameters, "en-us");
           result = _rsExec.Render(_invoice.ExportFileFormat,
                    devInfo,
                    out extension,
                    out encoding,
                    out mimeType,
                    out warnings,
                    out streamIDs);

                FileStream stream = File.Create(_excellocation, result.Length);
                stream.Write(result, 0, result.Length);
                stream.Close();

Thank you
0
Hello, how to back scroll in datagridview.

private void button73_Click(object sender, EventArgs e)
        {
            dotaz2AdvancedDataGridView.HorizontalScrollingOffset = dotaz2AdvancedDataGridView.HorizontalScrollingOffset + 30;
        }
      //work

        private void button74_Click(object sender, EventArgs e)
        {
            dotaz2AdvancedDataGridView.HorizontalScrollingOffset = dotaz2AdvancedDataGridView.HorizontalScrollingOffset - 30;
           //not work - error [b]System.ArgumentOutOfRangeException[/b]
        }

Open in new window



dotaz2AdvancedDataGridView.HorizontalScrollingOffset = dotaz2AdvancedDataGridView.HorizontalScrollingOffset - 30;
//not work - error System.ArgumentOutOfRangeException
0
Hello,
Back when C# came out; I did not know how to pronouns this combination of C and a # (sharp).  Talking to a  developer, he chuckled when I said "C pound."
And now, when "reading" about generic decorators; it is not written as to  how to pronouns these;
*args, **kwargs
Might any one have the phonetics /fəˈnediks/ on these two decorators;
*args, **kwargs

Thanks
0
I am struggling to get a handle on this problem.

I have a textbox on Gridview control:

<asp:TextBox ID="txtboatRegNo" style="width:270px;margin-left:195px;" runat="server"></asp:TextBox>

Open in new window


and a textbox on Repeater control:

<asp:TextBox ID="txtARegNo" style="width:270px;margin-left:195px;" runat="server"></asp:TextBox>

Open in new window


The values for both textbox controls are the same.

The current process asks user to enter his registration number on Griview and the click next to go next page.

On next page, there is a different set of requirements that asks user to once again, enter the same registration number.

We see this as being extremely inefficient.

So, we decided that once a user enters his/her registration number on txtboatRegNo on Gridview, that value should auto fill the txtARegNo on Repeater control.

So far, the following query is not working in that it is not auto filling the value enter in Gridview on the Repeater control.

Does anyone know how to resolve this?

This is the script I have been working with:

  <script type="text/javascript">
         $(function () {
             $('[id*=txtboatRegNo]').change(function () {
                 $('[id*=txtARegNo]').val(this.value);
             });
         });
 </script>

Open in new window


Thanks in advance
0
Hi there !

I would like to write separate method to compare 2 objects created from 2 different classes but both classes have similar property names.

Sample code:
ClassA
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string StreetName { get; set; }
}


ClassB
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string Address { get; set; }
}

Open in new window

Now, the output of custom method shud do following:
* returns true when similar property names hold same values in ClassA & ClassB objects.
* vice versa, returns false when similar property names DO NOT hold same values in ClassA & ClassB objects.
* In both above scenarios, just skip what values are hold in different property names and continue.

Also I would like to know if there any Nuget packages or any external tool available by which we can achieve above without writing any code.

Thanks in advance
0
PeopleSoft Has Never Been Easier
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Do you know any out of box solution that can get map shown
Different place type !? I am looking for a way to show a map that have campground,  national park, theme park, and any small local park

I also look for a map to show all local events

I understand we can use API google map but try to get something up without impacting too much customized coding

We use it on aspnet c# thanks
0
Anyone knows how to get year, model, and maker for all Rv or motorhome or trailers? I have a project to build website that need to get Rv information for insurance quote ...


Thanks
0
Do u know any API or database I can get for my website that I want to build? I am building website that doing auto car insurance in c# n aspx

Thanks
0
When I click the button(add to cart) after selecting a qty from my dropdownlist, my cart page will show qty from the ddl. However the cart only shows 1 qty for the item in the cart page no matter what qty I select for my ddl !! Its only each time that I click the button that the qty in the cart page will increase... how do u change this??

This is the add to cart button code
  protected void btnAdd_Click(object sender, EventArgs e)
    {
        string iDetailID = detail.EventDetail_ID.ToString();
        ShoppingCart.Instance.AddItem(iDetailID, detail); 

        int ddlAmount, participants, itemNr;
        if (ValidateInput(out ddlAmount, out participants, out itemNr))
        {
            l1.Text = "";
            SetCookie();
            UpdateEventParticipantes(ddlAmount, itemNr);
            Response.Redirect(string.Format("Detail.aspx?id={0}", itemNr));
        }
    }

Open in new window

My cart page
  protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadCart();
        }
    }
    protected void LoadCart()
    {
        gv_CartView.DataSource = ShoppingCart.Instance.Items;
        gv_CartView.DataBind();
        decimal total = 0.0m;
        foreach (ShoppingCartItem item in ShoppingCart.Instance.Items)
        {
            total = total + item.TotalPrice;
        }
        lbl_TotalPrice.Text = total.ToString();
    }
    protected void gv_CartView_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Remove")
        {
            lbl_Error.Text = "Message : " + e.CommandArgument.ToString();
            string detailId = e.CommandArgument.ToString();
            ShoppingCart.Instance.RemoveItem(detailId);
            LoadCart();
        }
    }

Open in new window

ShoppingCart CLASS

Open in new window

0
I am creating windows application using c# 2010, here i am using data grid view for billing purpose, here i want, i am enter first cell values in below method and how to show multiplication result on second column

Ex :

first cell       second cell
10x10         100

how to create above method give me any one idea
0
Greetings Experts,

Background:
ASP.NET 4.6.1
C#
Material-Components-Web (to add Material Design to page)


I'm trying to use Material-Components-Web in an ASP.NET Forms project. The following code shows an icon inside a button.

<button type="submit" name="ctl00$maincontent$btnRefresh" id="maincontent_btnRefresh" class="mdc-fab mdc-fab--mini lexbe-fab">
        <i class="material-icons"> refresh</i>
</button>

protected void btnRefresh_Click(object sender, System.EventArgs e)
{
       // Called.
}

Open in new window


If I click near the edge of the button it works and the event handler in code behind gets called.
However, if I click directly on the icon, then the even handler is not called.

Question: What's the right way to get the button to call the event handler even if it is the child icon that is clicked?

Thanks!
0
Hi EE,

in vb.net, I have a TreeView control.

each nodes (lets say I have 5) like this :

Apples
Tomatoes
Oranges
Grapes
Bananas


each of them has an "ID" or a "Code" in the background.  lets say its :

Apples     [0020]
Tomatoes   [0025]
Oranges     [0060]
Grapes     [0061]
Bananas    [0110]


My 2 questions are :

1) If I have a button "Add item" is it possible to add a node at the end of the tree, the user writes the name of the fruit, then he could drag the new node somewhere in between 2 fruits to place it where he wants it ?

2) since there are codes to each fruit, if user drags it in between [0025] and [0060] I would like the code to be automatically created at 0026 to be placed in between !

But it goes to another question, what If after the user creates another one and wants to place it in between of 0025 and 0026 ? now there is not space anymore between the codes ! we would have to increment of + 1 all the codes then place it in between.

so thats my issues... I realyl need help on this...
thank you.

(I am using fruits as an example but this is for work in our Logistic menu in our system. right now its not efficient, I have created the TreeView and reading values from SQL, but im stuck there for the rest)
0
The Task To try and recognise peoples names (mainly last names) in any Office files (Outlook, Word or Excel).  Basically I can reduce all these items to just a text string.  The reason that I would like to do this is that I want to add an item to the Office context menu when a name is clicked on with a right click of the mouse.

My research pretty much looks like this with respect to Regex;

StackOverflow Forum Question
StackOverflow question
StackOverflow question

I have also found this library and have set up an example with one of the regular expressions here.

Here is a link to my regex101 code with text.. You can see that I need to fix this for German Umlauts.

Reading up on human name recognition and Regex there are some people that do not think it is a great idea. I have therefore thought of the following set of steps which still involves Regex but should not miss any names.

1. Create a simple Regex that collects all words which start with a capital, is longer than 2 characters and only has alpha characters
2. …
0
I have codes below and everything works fine except I get alert message below

The process cannot access the file 'c:\abc.xml because it is being used by another process

Just FYI, the xml is used for a website with around 20 users.

   public static DataTable GetUniquePhoneNo(string accountPhoneNo)
        {
            string clientPhoneNo = string.Empty;
            string inputFilePath = filePathUserMessagesAll;
            DataTable dt = new DataTable();
            dt.Clear();
            dt.Columns.AddRange(new DataColumn[]
           {
                new DataColumn("PhoneNo",typeof(string)),
                new DataColumn("Client",typeof(string)),
                new DataColumn("DateCreated",typeof(string))
           });
            XDocument xdoc = null;
            using (XmlReader xr = XmlReader.Create(inputFilePath))
            {
                xdoc = XDocument.Load(xr);
                var query1 = from t in xdoc.Descendants("User")
                             where t.Element("From").Value.ToLower() == "+1" + accountPhoneNo.ToLower()
                             select new
                             {
                                 To = t.Element("To").Value,
                                 FullName = t.Element("FullName").Value,
                                 DateTimeSent = t.Element("DateTimeSent").Value
                                 //DateTime.Parse(txtDatepicker_end.Text).ToString("YYYY-MM-dd");
                             };
     

Open in new window

0
Free Tool: SSL Checker
LVL 9
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

I have this view and I am tying to add the genre.Albums in here but the value for it is NULL
GenreMenu.cshtml.

@model IEnumerable<MvcMusicStore.Models.Genre>
<ul id="categories">
    @foreach (var genre in Model)
    {
        <li>@Html.ActionLink(genre.Name, 
                "Browse", "Store", 
                new { Genre = genre.Name }, null)
        </li>
    }
</ul>

Open in new window


// the value for the albums Count needs to appear next to each genre.name.., how to do this?


Meanwhile, I have another View page, that give me what I need "Albums.Count()"

Browse.cshtml
@model MvcMusicStore.Models.Genre
 
@{
    ViewBag.Title = "Browse Albums";
}
 
<div class="genre" >

    <ul id="album-list">
        @foreach (var album in Model.Albums)
        {
            <li>
                <a href="@Url.Action("Details", new { id = album.AlbumId })">
                    <img alt="@album.Title" src="@album.AlbumArtUrl" />
                    <span>@album.Title</span>
                </a>
            </li>
        }
    </ul>
</div>

Open in new window



How Can I extract the value from Albums.Count() and add it to GenreMenu.cshtml page?
thanks
0
private Form2 otherForm = new Form2();
textBox1.Text = otherForm.textBox1.Text;

The code not work. Error: CS0122 - is inaccessible due to its protection level!

Pls help :/
0
Hello sir,

I create a setup for my project, i need uninstaller file to uninstall my project. but i know i can go to control panel and uninstall but i want want professionally to uninstall it.

thanks in advance
0
I have a project where I need to programmatically (C#) pass a function the name of a parent Task List item and return a list of the children listitem IDs.

I see that there is a ParentID, but it has values that don't really help.  Such as 1;1 for several and 2;2 for several more.  Nothing about those values tell me the ID of their parent.

Any advice on this would be greatly appreciated.
0
hi experts my code is like that check on table1 if textbox1.Text exist if yes go to table2 and check if textbox1.text exist and if textbox2.Text exist if they exist open the form if not insert them and open the form and if textbox1.text exist and textbox2.text doesn't exist close form

i wrote this :

MySqlConnection con = new MySqlConnection(connectionString);
            i = 0;
            con.Open();
            MySqlCommand cmd = con.CreateCommand();
            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "select * from informat where u_ser = '" + metroTextBox2.Text + "' ";
            cmd.ExecuteNonQuery();
            DataTable dt = new DataTable();
            MySqlDataAdapter da = new MySqlDataAdapter(cmd);
            da.Fill(dt);
            i = dt.Rows.Count;
            int userial = metroTextBox2.Text.Length;
            if (userial >= 5 || metroTextBox2.Text == null)
            {

                MySqlConnection conet = new MySqlConnection(connectionString);
                conet.Open();
                MySqlCommand cmsd = conet.CreateCommand();
                cmsd.CommandType = CommandType.Text;
                cmsd.CommandText = "select * from alred  where u_ser = '" + metroTextBox2.Text + "'and u_ip =  '" + textBox1.Text + "'";
                cmsd.ExecuteNonQuery();
                DataTable ddts = new DataTable();
                MySqlDataAdapter ddas = new MySqlDataAdapter(cmsd);
                ddas.Fill(ddts);

         

Open in new window

0
i have created a c# code for adding dkim signature with the mail. I'm using IIS smtp server as host but result showing with dkim fail report because of bad signature or message altered. I found some other article showing we need to setup a separate plug in for activate dkim in iis smtp server like(EA Send mail,Think DKIM..) Is it good to go with IIS smtp related dkim plug in or pure c# code sign in(IIS Smtp) or go with other mail server that support DKIM features.
0

C#

91K

Solutions

24K

Contributors

C# is an object-oriented programming language created in conjunction with Microsoft’s .NET framework. Compilation is usually done into the Microsoft Intermediate Language (MSIL), which is then JIT-compiled to native code (and cached) during execution in the Common Language Runtime (CLR).