|
I have tried searching and everything I find says to use "WebRequest.UserAgent" but this isnt a valid option in my solution to add. Am I doing something wrong? The script is pulling content from the webpage 100% correctly, I just want to be able to specify the user agent also.
byte[] data = System.Text.Encoding.ASCII.GetBytes(FormVariables);
System.IO.Stream os = null;
WebRequest request = null;
WebRequest.DefaultWebProxy.Credentials = CredentialCache.DefaultCredentials;
request = WebRequest.Create(URL);
request.ContentType = "application/x-www-form-urlencoded";
request.Method = "POST";
request.ContentLength = data.Length;
request.Timeout = 420000;
os = request.GetRequestStream();
os.Write(data, 0, data.Length);
os.Close();
System.Net.WebResponse resp = null;
resp = request.GetResponse();
System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());
strResponse = sr.ReadToEnd().Trim();
|
|
|
|
|
Good Evening,
currently I am doing a small program which copies a file from one folder to another folder. The destination folder is the "Fonts" folder which holds all fonts of my system. Currently my code looks like this:
FileIOPermission f2 = new FileIOPermission(FileIOPermissionAccess.Write, "C:\\Windows\\Fonts\\");
f2.AddPathList(FileIOPermissionAccess.Read , origin);
try
{
System.IO.File.Copy(origin, destination);
}
catch (UnauthorizedAccessException ex)
{
MessageBox.Show(ex.ToString());
}
When I start debugging, the debugger tells me that I dont have permission for C:\Windows\Fonts\"filename". Which confuses me a bit since I thought I already got write permission to "C:\Windows\Fonts\". What am i doing wrong?
P.S.: I am using Windows Vista SP1 64-Bit
Thanks for your help and advices
|
|
|
|
|
Can someone give me some help on this please, since i dont know what i am doing wrong? I used a messagebox to have a quick look at the permmission i requested and it says i asked for write permission for C:\Windows\Fonts and read permission for the folder in "origin".
Is there something else I have to do?
|
|
|
|
|
I have an ASP.NET application that I'm upgrading, and my new development box is Windows Vista and VS.NET 2008. It's well documented that Jet is not installed in Vista, and will not run on it. Does anybody know what the connection string is that I should be using, and what provider needs to be installed? I checked http://www.connectionstrings.com[^], but couldn't quite find what I was looking for. I figure SOMEONE has already been down this road, and thought I'd ask.
Thanks in advance.
|
|
|
|
|
Hi,
I'm using Access on Vista with OLEDB
connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+file+";User Id=XXX;Password=YYY;";
Every constr you ever needed[^] is here.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
That's what I was using when I migrated the project to my new development box, but it says that it can't find the Jet provider. Research on Google says that you can't use Jet in Vista; the installer won't even install it. How did you set it up?
|
|
|
|
|
I don't recall there being any issue.
I installed Access2003, Visual Studio, and lots of other stuff on a Vista Home Premium machine.
Then created a C# app that works on an existing mdb file.
What installer is complaining? and what is its message?
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I don't kown why..., but when I adding attachment (Bitmap) from MemoryStream, it dosn't work, because I receive mail with picture, but it has 0 KB. Bitmap adding as attachment from FileStream, work correctly... (sorry, my bad english)
thanks
Here is my snippet code:
...
Bitmap bmp;
...
MemoryStream = new MemoryStream();
bmp.Save(memStream, ImageFormat.Jpeg);
...
ContentType contentType = new ContentType();
contentType.MediaType = MediaTypeNames.Image.Jpeg;
contentType.Name = "screen";
MailMessage mail = new MailMessage();
...
mail.Attachments.Add(new Attachment(memStream, contentType));
...
SmtpClient.Send(mail);
|
|
|
|
|
I don't see where you are even getting the bitmap?
Bitmap bmp; <---- Empty
MemoryStream memStream = new MemoryStream(); <--- Empty
bmp.Save(memStream, ImageFormat.Jpeg); <---- Still Empty
Where are you actually getting the bitmap data from? As far as I can see that is why it is 0kb because you are not giving it any data
|
|
|
|
|
shouldn't you "rewind" the stream?
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
In memory buffer, there is a snap shott from screen.
This code is not completly, if i try save image from memory buffer to file.. it's ok
|
|
|
|
|
did you try memStream.Position=0; // rewind ?
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
now I try it, but nothing
MemoryStream memStream = new MemoryStream();
memStream.Position = 0;
bmp.Save(memStream, ImageFormat.Jpeg);
|
|
|
|
|
Have a cup of coffee, then do the rewind after saving the image.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
omg.. very very thanks..
|
|
|
|
|
Thank you! Was having the same problem.
|
|
|
|
|
This might be a simple answer but I cannot seem to think of it. What would be the best way to send reports every monday at 7am. I guess what I am asking what is the best way to determine the time is 7am and send the report?
Run a timer every second and if the day is Monday and the time is exactly 7:00am send it? Or is there a better way I am just not thinking of?
|
|
|
|
|
Create a console executable and schedule it using windows task scheduler. You can also go for a scheduled windows service but there are opinions that "services are not meant to be scheduled".
जय हिंद
|
|
|
|
|
I forgot to mention that this was going to be a Windows Service
|
|
|
|
|
then use a timer; however don't rely on exact timing, you might miss a start if the system happens to be busy.
Instead use a time window, and check the current date is different from the date it ran last.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Make sure you handle the case where the machine may be rebooted or your service restarted, even during the reporting time window.
|
|
|
|
|
This seems the most simple way... basically set the windows scheduler to run the application at certain times. I like it... I will give it a try
|
|
|
|
|
Use a timer.
1- Calculate the amount of time until 7am.
2- Set a timer to wake you up when that amount of time has passed.
3- When the timer wakes you up, do your stuff.
4- Goto 1.
Go with D@nish's suggestion, much better.
|
|
|
|
|
Firstly - I'd set up some method by which each report can be scheduled to be run and/or sent at a different time (because that's bound to be a requirement in the future!)
Get your collection of scheduled times and convert them to 'next run Date Times' sorted in ascending order. Remember you will need some way of telling when a report was last run, too, so that a report scheduled for 7:00 does not also get run at 7:01)
Calculate teh time from NOW to the first entry in your list. Set a timer for this duration (less a short amount to cater for discrepancies.
Decide whether you will allow new reports to be added into the current schedule between NOW and the next scheduled report time, or reports to be removed from the schedule. (if you do, you need some polling to detect a change, and restart the algorithm .
On 'waking' re-build the collection (in case something has changed). If the next scheduled report is due (or past due) run it, and update it's 'Last Run' date/time then re-create the collection (catch multiple reports scheduled simultaneously).
You need to decide (assuming you implement the polling mentioned above) how time critical you need it to be. If +- 5 minutes is going to be OK - then your polling can be once every five minutes (remembering that your polling should probably be paused while any report is in progress)
Hint for young players; When I had somethinglike this implemented a few years ago, the developer created the list of reportsw by selecting WHERE ScheduledTime > TimeRightNow - this doesn't work if the time the report is scheduled for has passed (because, for example, teh previous report took a long time to run) - you need to include rpeorts based on whether the report has been run for the last scheduled time, not whether that time has passed.
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
Maxxx,
Thats for your advice. Although I think that is getting a little too complex for me right now. Maybe its late.. I dunno.
I think right now.. the easiest solution for me is the console application. Although I much rather do a Windows Service so I can learn to use it more, I will try this right now...
Maybe if I had a close example of your suggestion.. like an article or something I could read to better understand how exactly you see it working.
|
|
|
|