Posts by Tiago S • 4,234 points
136 posts
-
4
votes2
answers350
viewsA: How to get the total memory occupied by the application?
You can use using System.Diagnostics; Process currentProc = Process.GetCurrentProcess(); long memoryUsed = currentProc.PrivateMemorySize64;
-
1
votes1
answer56
viewsA: Field within a variable dynamically using array
The error is here: imagem[0] = ConvertToBytes(file); byte[] imagem = new byte[6]; foreach (string item in Request.Files) { HttpPostedFileBase file = Request.Files[item] as HttpPostedFileBase;…
-
1
votes1
answer546
viewsA: Get CPU usage of a process in int C#
You can use the class PerformanceCounter that is in namespace System.Diagnostics public int GetCpuUsage() { System.Diagnostics.PerformanceCounter cpuCounter; cpuCounter = new…
-
2
votes1
answer375
viewsA: Format Gridview Time
Use it like this: DataFormatString="{0:HH:mm}" The HH has to be capitalized Example: <asp:BoundField DataField="hora" HeaderText="Hora" SortExpression="Hora" DataFormatString="{0:HH:mm}"…
-
3
votes1
answer180
viewsA: Does Tempdata lose property when using Response.Redirect?
Use the ViewBag for it exists until the end of the execution of response. On the controller: if (Session["Login"] == null) { ViewBag.msg = "É necessário realizar o login para acessar esta página!";…
-
1
votes2
answers2833
viewsA: How to upload . txt file and save to a directory using c# net mvc?
You are using a class that contains an enumerator of HttpPostedFile. The correct thing would be for you to receive the files via HttpPostedFileBase. [HttpPost] public ActionResult…
-
0
votes1
answer82
viewsA: Implement Dictionary as C#interface
Your class Item has to this: oublic class Item : IItem { public int _SearchType; public int SearchType { get { return this._SearchType; } set { this._SearchType = value; } } Dictionary<string,…
-
0
votes2
answers314
viewsA: Datasource Configuration Error in VS Community 2015 C# + Reportviwer + Mysql
Try this solution Close the Visual Studio Remove Mysql Connector/Net embedding Install Mysql Connector/Net as you did before deleting (typical/ custom). Open the Visual studio Deletes all…
-
3
votes3
answers603
viewsA: Problem sending model to controller
You can put all client properties with the html tag <input type="hidden"/> int index=0; @foreach (var x in @lstCliente) { //Cliente <input type="hidden" name="ListaClientes[@index].Nome"…
-
8
votes2
answers1555
viewsA: Show zero on the left using the Tostring method
Abbreviated form (Default) Format: .ToString("D[n]") or .ToString("d[n]") The n is optional and means the size of the string, and if the number does not reach the set size a string is completed with…
-
0
votes1
answer311
viewsA: Datetime null 01/01/0001 - Error in selection (Winforms+Layers bll,dal,model) C#
Probably your reader["DataPagamento"] is null and you are calling a method from a null instance which causes an exception. Make this change: if(reader["DataPagamento"]!=null) caixa.DataPagamento =…
-
1
votes1
answer664
viewsA: Bug in the build?
As already stated in the comments, you probably removed the method private void listView_SelectionChanged(object sender, SelectionChangedEventArgs e) Two solutions: 1)Remove reference Go on the…
-
1
votes1
answer35
viewsA: Parameter’s passage
You can use the class Convert, to convert to date textBlock8.Text = Convert.ToDateTime(reader.GetString("Data")).ToString("dd/MM/yyyy") or use the DateTime to give a Parse in string textBlock8.Text…
-
6
votes2
answers439
viewsA: Entity Framework | Double property that allows null
You can cast for double ocorrencia.Avaliacao = (double)5.00;
-
0
votes2
answers278
viewsA: Special character encoding before going to the SQL database
HTML First implements the function below, to create an element and take your html function HtmlEncode(s) { var el = document.createElement("div"); el.innerText = el.textContent = s; s =…
-
3
votes1
answer222
viewsA: C# How to send the value of the numericUpDown to the textbox in Hexadecimal?
Just do a parse for whole and call the method ToString with formatting X2 for two hexadecimal digits. textBox1.Text = ((int)numericUpDown1.Value).ToString("X2");…
-
0
votes1
answer56
viewsA: increment field with lambda
Solution: long maxes = bancodados.embalagens_80.DefaultIfEmpty() .Where(x=>x==null||x.EMP_ID_80 == EMP_ID) .Max(x => x == null ? 1 : x.EML_ID_80 + 1) ; In the above code I am selecting all…
-
4
votes1
answer459
viewsA: Error Connecting Postgresql to Entity Framework
You need to add the tag remove before the tag add, in case there already exists the Preview it remove and then add again. <DbProviderFactories> <remove invariant="Npgsql"/> <add…
-
5
votes1
answer777
viewsA: How to transform a string into HTML C#
When you have a string of html it is not rendered in DOM, why this string can be render it is necessary to call the method Html.Raw() passing to string html. The method Html.Raw() Transforms the…
-
0
votes2
answers1186
viewsA: Entity Framework: Object Update Error
You need to add the obj in the DbSet<T> Example: public void AtualizarCliente(Cliente obj) { banco.Cliente.Add(obj);//Você adiciona o obj modificado no cliente Atualizar(obj);//Agora você pode…
-
2
votes1
answer57
viewsA: How to foreach in each select using EF6?
The solution I found was: First you list everything and then you apply the filter. var list = new List<String>(); list.Add("Casa"); list.Add("Apartamento"); var connection =…
-
0
votes1
answer538
viewsA: "Uncaught Syntaxerror: Unexpected token :" error when trying to bring data in JSON format from another URL
I had to make some changes to make it work: dataType: "jsonp" for dataType: "json"; jsonpCallback: "logResults" for success: logResults $.ajax({ url: "https://blockchain.info/pt/ticker", dataType:…
-
0
votes1
answer152
viewsA: c# when pressed at the same time alt + F4 opens a new form
To open a new form by clicking alt+F4: Form 1: Set the property KeyPreview as true; this.KeyPreview = true; Sign the Keydown Event; this.KeyDown += Form1_KeyDown; Complete; public Form1() {…
-
2
votes2
answers124
viewsA: Send data from one method to the other in the same Activity
You just pass to a private variable in the class. private String value; private void PegarNome(){ //Aqui eu consigo um valor onde não posso chamar no outro método, que é o filename value = filename;…
-
5
votes1
answer570
viewsQ: What is the difference between Ajax.Beginform and Html.Beginform in Asp.net MVC
Working with web inasp.net mvc, I saw that it is possible to use Ajax.BeginForm() and Html.BeginForm(). What is the difference between the Ajax and that of Html?…
-
1
votes1
answer425
viewsA: Coloring words from Richtextbox
You can use the Regex to select the double-quote string and then add Ex: private void ColorirRichTextBox() { string[] linhas = richTextBox1.Lines; foreach (var item in linhas) {…
-
1
votes1
answer119
viewsA: How to get the content of a tag from a Linq query?
The problem is that you are trying to access the element Root again. The following amendment already solves your problem: root.Elements("pessoa").Select(x => (string)x.Element("nome")).ToList();…
-
4
votes1
answer133
viewsA: Error converting bitmap to pictureBox on C#?
The problem is in the way you are setting the picturebox the correct is pictureBox1.Image=myIcon
-
-1
votes1
answer748
viewsA: Object reference not defined for an object instance. C# (on installation)
The problem may be in the method Equals(...), it is necessary more details of your problem to know exactly what happens The problem could be here: PDV.Status.Equals("False"); Or here:…
-
1
votes1
answer250
viewsA: How to create a URI Scheme
You need to register your URI Scheme in the windows registry follow the path of the registry: HKEY_CLASSES_ROOT/ your-protocol-name/ (Default) "URL:your-protocol-name Protocol" URL Protocol ""…
-
7
votes1
answer360
viewsA: How do I add Google Analytics to my Android app?
Project setup Update the file AndroidManifest.xml of your project to include permissions INTERNET and ACCESS_NETWORK_STATE: <manifest xmlns:android="http://schemas.android.com/apk/res/android"…
-
0
votes3
answers48
viewsA: How to store which Navigation Drawe item I selected
I do something very little like what you are looking for, in my case is automatic login. After the user login in my app I save the user and the password and the next time he enters I check if the…
-
5
votes2
answers1476
viewsQ: How to leave variables privately in Javascript?
How to leave a private variable, because I had trouble using the same variable name that was already implemented in another JS file and that I didn’t remember. How to create this private variable to…
-
9
votes1
answer1445
viewsA: How to Set and Get Application Version
To recover the app version use: PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); String version = pInfo.versionName; int verCode = pInfo.versionCode; The easiest and…
-
2
votes1
answer283
viewsA: How to edit data (just numbers) and calculate their values on a Datagrid?
The problem is that you need to make Binding with a property. How you are using a Linq class create a column in the table tabMaquinaParada only for the system to accept this new field.* This…
-
0
votes2
answers155
viewsA: Observablecollection does not Binding
The Observablecollection is a class that makes "Binding" with the itemSource property. So only the elements that have that property do the "Listens" of the collection. You are Binding with a…
-
2
votes1
answer553
viewsA: redirect 404 error page with Javascript
You can use the setTimeout and redirect to the index.html. On page 404 includes this script: <script> window.setTimeout(function(){ window.location = "http://www.pt.stackoverflow.com";…
javascriptanswered Tiago S 4,234 -
3
votes1
answer577
viewsA: java.lang.Numberformatexception: Invalid double: ""
Your mistake is that you are trying to convert something empty into double. Solution: Check if the value and quantity field are empty before converting. In the solution below I am setting the…
-
6
votes2
answers3642
viewsA: How to call explicitly and implicitly an Activity on Android?
1 - Implicitly: In the AndroidManifest.xml declare a intent filter for your activity: <activity android:name="com.example.counter.MainActivity" android:label="@string/app_name" >…
-
0
votes2
answers2338
viewsA: pass parameter to another html page
In html you can use sessionStorage to pass the parameter. sessionStorage.setItem('key', value); and to recover: sessionStorage.getItem('key'); In your case it would look like this: Html 1 function…
-
2
votes4
answers614
viewsA: Writing effect using javascript, setInterval does not work
Error is in two parts: 1 setInterval. setInterval(escrever("teste"), 1000); the correct is setInterval(function(){escrever("teste")}, 1000); 2 Loop of repetition. for (i = 0; i < text.length;…
-
1
votes1
answer1266
viewsA: How to update an apk without uninstalling the current one?
You can use this: protected String doInBackground(String... sUrl) { String path = "/sdcard/YourApp.apk"; try { URL url = new URL(sUrl[0]); URLConnection connection = url.openConnection();…
-
0
votes3
answers14451
viewsA: Turn the first letter of a string into uppercase?
You can enter the features of the previous answers in a Static class and access it from anywhere. Implementation: public static class StringExtends { public static string FirstCharToUpper(this…
-
0
votes2
answers97
viewsA: Error loading Listview on a Listfragment
Instead of getActivity().getApplicationContext() utilize BakeryFragment.this @Override public void onActivityCreated(@Nullable Bundle savedInstanceState) {…
-
1
votes1
answer463
viewsA: how to put sound effect when clicking the button
You can use it like this: Activity import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public…
-
5
votes2
answers664
viewsA: What are the advantages of Parallel.Foreach in C#?
Depends on the application. If you have a lot of data to be processed and the order does not import the best is parallel processing (Parallel.Foreach()), otherwise the best is foreach or other loop…
-
7
votes2
answers664
viewsQ: What are the advantages of Parallel.Foreach in C#?
Working with C# I saw that we have the option to work with parallel.ForEach(). What is the advantage of working with her and not the foreach?
-
2
votes2
answers87
views -
2
votes1
answer55
viewsA: Is there any way I can save a site from a published user PC file?
You can perform download operation and let it choose the location to save. public FileResult Download() { byte[] fileBytes = System.IO.File.ReadAllBytes(@"c:\folder\myfile.ext"); string fileName =…
-
1
votes1
answer307
viewsA: Smooth scroll bar
Insert this code into your .js and it will work. $('a[href^="#"]').on('click', function(event) { var target = $( $(this).attr('href') ); if( target.length ) { event.preventDefault(); $('html,…