User Profile
Collapse
-
Try setting the correct headers for the HttpWebRequest. The class above WebClientEx should take care of keeping cookies between requests as long as you keep them within the using clause. -
To explain further:
Code:public class WebClientEx : WebClient { private CookieContainer cookies = new CookieContainer(); protected override WebRequest GetWebRequest(Uri address) { WebRequest retVal = base.GetWebRequest(address); if (retVal.GetType() == typeof(HttpWebRequest)) { ((HttpWebRequest)retVal).CookieContainer = cookies; }
Leave a comment:
-
This class should help you I was just about to post it in my own old question anyway:
Code:public class WebClientEx : WebClient { private CookieContainer cookies = new CookieContainer(); protected override WebRequest GetWebRequest(Uri address) { WebRequest retVal = base.GetWebRequest(address); if (retVal.GetType() == typeof(HttpWebRequest)) {
Leave a comment:
-
You could also make a custom control with three boxes that you then add through code which is probably easier to position and work with.Leave a comment:
-
DonBytes replied to Question about C# Strings, populating variable values within a string at runtimein .NETIf it's not to long strings you could write them prepared for String.Format when you load them up such as:
Code:String sBody = "ComputerName: {0}\r\nError: {1}";
Code:email.Body = String.Format(sBody, sComputerName, sError);
Leave a comment:
-
Been a long time since I did anything in VB but the File class has a method called OpenRead if I recall correctly.
So perhaps something like this would work:
Code:Using objSR As StreamReader = New StreamReader(File.OpenRead(sLicenseFile)) End Using
Also there is a FileStream class where you can specify FileAccess which might help if the above code doesn'...Leave a comment:
-
C# Application CookieContainer
Wondering if anyone had problems with the CookieContainer s, I was making a program that logs onto sites, check for news and then reports back.
All cookies domain in response.cookie s is marked as site.com except for one that is marked as .site.com for some reason this doesn't make it back to http://site.com when I try to check the messages page after doing the login.
If I override the WebResponse in WebClient and add... -
-
It only misbehaves when you feed root directory without slash as first argument. Always has as long as I've used it. So does:
Code:DirectoryInfo dir = new DirectoryInfo("C:")
Code:Path.Combine(@"C:\Some Dir", "File.txt"); Path.Combine(@"C:\Some Dir\", @"File.txt");
Leave a comment:
-
If sourceofdata is another table that looks the same you can use:
Code:foreach (DataRow dr in sourceofdata.Rows) { ... }
Code:foreach (DataRow dr in sourceofdata.Tables[0].Rows) { ... }
Leave a comment:
-
-
As far as I know you can't turn on auto increment on a table that looks like that you'd have to do something like:
Step 1:
Code:sp_rename 'TableName', 'TableName_old';
Code:CREATE TABLE [TableName] (Id INT IDENTITY, Name VARCHAR(50)); INSERT INTO TableName (Name) SELECT Name from TableName_old;
Leave a comment:
-
I believe you'd have to create it yourself using XmlDocument and CreateElement for each row/column. You can save it and then load it (if it exists) prior to adding items.
I really don't see any other way of getting the extra level (<item>) in there neither.Leave a comment:
-
A bit overkill but as I am pretty much certain copy and xcopy can't do what you want here goes:
Code:robocopy.exe . "C:\Destination Directory" Filename /XC
Code:robocopy.exe "C:Source Directory" "C:\Destination Directory" Filename /XC
Leave a comment:
-
Yeah, C# can handle strings with spaces whereas arguments can not, but when chaining batch files it's easy to get lost on where you need to quote and where you do not.
Also, looking through it again, the space first in arguments is not needed as it'll be separated anyway.Leave a comment:
-
You could copy it with C# and set overwrite to false? or is that some scheduled task that runs beside your program?Leave a comment:
-
According to row 13 of the posted code he does set it though. However he sets it using this:
Code:psi.WorkingDirectory = InQuotes(pathToScripts);
Code://----------------------------------------------------------------------------------------------------------
Leave a comment:
-
If [DropDownStyle] is set to [DropDown] you can just do:
Code:comboBoxName.Text = "12";
Leave a comment:
-
Can't really help you with your problem but I just recently did this for the normal Save As dialog box (the one Notepad etc use) and the way I ended up doing it was by the Registry. Here's an export of the keys:
Code:Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\comdlg32\PlacesBar] "Place0"=dword:00000000 "Place1"=dword:00000011
Leave a comment:
-
Code:sText = Regex.Replace(sText, "</?(font|div)[^>]*>", String.Empty, RegexOptions.IgnoreCase);
Leave a comment:
No activity results to display
Show More
Leave a comment: