|
you have 2 choices
either store the data locally as CG suggested or use form.hide(), this will require you to manage the open form differently but the form values will not change between open/hide events.
|
|
|
|
|
when a PDF file is opened in IE, I have to save that PDF without asking the user to save.
How to do this in c#?
Normally I am able to save the HTML pages opened in IE, but PDFs are not saved.
Is there any way to save the currently opened PDF without asking user to save?
|
|
|
|
|
No, there is no way. Because, it's acrobat, and not IE, that is showing the file, it's acrobat you'd need to interact with.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Then i suggest try using printer driver to PDF. If you select print, and then those drivers will save as PDF
svt gdwl wrote: Is there any way to save the currently opened PDF without asking user to save?
You coud write code to automatcly print to PDF through driver
|
|
|
|
|
I get the following error. I don't know what's wrong with that. Can anyone suggest solution to this problem?
Sorrie i'd to post this link as i din't find any where to post the image.
http://img299.imageshack.us/img299/4097/errortck.th.jpg
Thnx
|
|
|
|
|
ROTFL !!!!
Your image is too small to read. Why not post the text here ? That's what most people would do.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Ah - you just posted the wrong URL. not a good sign.
It probably means you're hitting F5, but you're trying to debug a release build and no debug build is present.
Or the build failed for some other reason. What does the output window say ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Yeah I was tryin to build and it shows the following errors:
Error 1 The type or namespace name 'AxVCProX' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\illusion\Desktop\C#\sample_chat_source_csharp\Form1.cs 25 11 Chat
Error 2 The type or namespace name 'AxVCProX' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\illusion\Desktop\C#\sample_chat_source_csharp\Form1.cs 41 11 Chat
Error 3 The type or namespace name 'AxVCProX' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\illusion\Desktop\C#\sample_chat_source_csharp\Form1.cs 554 50 Chat
Warning 4 Cannot load type library for reference "AxVCProX". Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)) Chat
Warning 5 Cannot load type library for reference "VCProX". Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)) Chat
Warning 6 The referenced component 'AxVCProX' could not be found.
Warning 7 The referenced component 'VCProX' could not be found.
I am a newbie to C# and i don't know how to fix these errors.
|
|
|
|
|
Looks like there's a library you need to register. That will be a COM dll you are missing.
If you want to learn C#, don't download code and try to compile it at random, buy a book and work through it.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Dear All,
i have following code to run 34 activities at same time, but it seems it doesent.
foreach(ListViewItem prv in des.lProvinces.CheckedItems)
{
if (prv.Text.Equals("All"))
continue;
pmuAccessPath=string.Format("{0}\\{1}\\NSPDatabase.mdb",des.DestinationFolder,prv.Text.Trim());
if (!Directory.Exists(Path.GetDirectoryName(pmuAccessPath)))
Directory.CreateDirectory(Path.GetDirectoryName(pmuAccessPath));
if (!File.Exists(pmuAccessPath))
File.Copy(des.SourceAccessPath,pmuAccessPath);
Finish fin=new Finish();
pnlControls.Controls.Add(fin);
fin.Dock=DockStyle.Top;
fin.lblProvince.Text=string.Format("Province : ({0})",prv.Text);
fin.lblProvince.Refresh();
Triplet triplet=new Triplet(fin,pmuAccessPath,prv.Tag);
ThreadPool.QueueUserWorkItem(new WaitCallback(runMultiple),(object)triplet);
Thread.Sleep(50); }
the method runMultiple, queries some tables from sql server 2005 and then inserts those into Access Database.
count of items is 34, for the first time it performs all but then it stops and executes only one by one.
like one gets finished and another starts.
i want to all should run at same time?
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
ThreadPool is optimized and it will not start 34 threads to do the job even if there are 34 items in the queue. If you want all 34 to be executing, create your own thread and execute on it rather than using ThreadPool . But huge number of threads will make problems.
Abdul Rahman Hamidy wrote: Thread.Sleep(50);
Why do you want to sleep here?
|
|
|
|
|
thanks for reply.
for sure haveing lots of threads are not adviseable, but in my case its only one time job.
so You mean i should use
I used following but didnt help
Thread t=new Thread(new ParameterizedThreadStart(runMultiple));
t.IsBackground=true;
t.Start((object)triplet);
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
modified on Wednesday, August 26, 2009 2:05 AM
|
|
|
|
|
Yes. Putting that inside the loop will start one thread on every iteration.
Abdul Rahman Hamidy wrote: but didnt help
How are you checking that it is not working?
|
|
|
|
|
well, Finish is a control which have progress bar and lables which gets updated on every transaction.
only one progress bar goes others are stop and does nothing.
when the one is finished then another starts. this shows that others are not working.
and at the same if open the access file then records are not in tables.
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
i make a program that load a photo to a pictuerbox.
when i cheng the dir of the pictuerbox and try to delete the first one there is an erorr happen(it can not delete the f:\j.jpg becaus it used by another process)
what can i do?
|
|
|
|
|
Fix your code. Hard to say more because you didn't post it.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Bitmap b=new Bitmap(@"d:\s.jpg");
pictuerbox1.Imege=b;
pictuerbox1.Imege.Save(@"d:\c.jpg");
File.Delete(@"s:\s.jpg");<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
|
|
|
|
sanforjackass wrote: pictuerbox1.Imege.Save(@"d:\c.jpg");
problem is with this line of your code.
you are deleting image but picture box still using it,
that why you getting error.
1 solution - try to set picturebox image to null before deleting it.
OR create bitmap from stream, like
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
PictrureBox.Image=Image.FromStream(fs);
fs.Close();
hope this would help
|
|
|
|
|
it did not work!!
any help?
|
|
|
|
|
What code you had tried, It worked for me.
|
|
|
|
|
i want to delete it
i tryed
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
PictrureBox1.Image=Image.FromStream(fs);
pictuer1.Image.Save(New Dir);
File.Delete(Dir);
fs.Close();
and it did not work
|
|
|
|
|
|
You are not closing the FileStream until after you try to delete the image, Therefore the image is still being used by the FileStream , hence the error message.
Modify your code:
using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read))
{
PictrureBox1.Image=Image.FromStream(fs);
}
pictuer1.Image.Save(New Dir);
File.Delete(Dir);
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
thanks as you say i only need to close theFileStream
|
|
|
|
|
Hi folks I know there are lots of different free ones out there.
But I wanted to have a go at somthing quick as a learning exercise.
I got as far as the code below, but am having trouble putting found URL's (i.e. 'eachLineValue') from a web page back into the WebRequest.Create(URL)
Do i need some sort of function around this that I can call recursively with different URL's ?
thanks Mark
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
namespace ShoppingDataExtractor
{
public partial class spider : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder();
byte[] buf = new byte[8192];
string initialURL = "http://www.bestpricedirectory.com.au/";
try
{
WebRequest myRequest = WebRequest.Create(initialURL);
WebResponse myResponse = myRequest.GetResponse();
Response.Write(myResponse);
Stream resStream = myResponse.GetResponseStream();
string tempString = null;
int count = 0;
do
{
count = resStream.Read(buf, 0, buf.Length);
if (count != 0)
{
tempString = Encoding.ASCII.GetString(buf, 0, count);
sb.Append(tempString);
}
}
while (count > 0);
Response.Write(sb.ToString());
Regex r = new Regex(@"href=\""(.*?)\""",
RegexOptions.IgnoreCase | RegexOptions.Compiled);
MatchCollection matches = r.Matches(sb.ToString());
foreach (Match match in matches)
{
Array values = match.Value.ToCharArray();
foreach (System.Char line in values)
{
File.AppendAllText(@"C:/Documents and Settings/Administrator/My Documents/Visual Studio 2008/Projects/ShoppingDataExtractor/spider.txt", ({0}) ,line);
sb.ToString();
}
}
myResponse.Close();
resStream.Close();
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}
}
}
|
|
|
|