|
Sorry, but you chose the wrong forum for your repost. You should be asking this in the ASP.NET[^] forum.
|
|
|
|
|
Hi all,
I am doing a very simple operation via c#.
1 I just copy an existing JPEG file in temp directory.
2 Then I open the copied Jpeg file from temp directory.
3 I try to delete the original Jpeg file and application crashes.
Please see below c# function for this:
using System.IO;
public void DeleteAfterCopyingOriginalImageFile(string strOriginalJpeg)
{
string strTempFolder = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "JpegTemp");
if (!Directory.Exists(strTempFolder))
{
DirectoryInfo directory = Directory.CreateDirectory(strTempFolder);
directory.Attributes = directory.Attributes | FileAttributes.Hidden;
}
string strTempJpeg = System.IO.Path.Combine(strTempFolder, "TempImage.jpg");
if (!File.Exists(strTempJpeg))
{
File.Copy(strOriginalJpeg, strTempJpeg);
}
Process.Start(strTempJpeg);
File.Delete(strOriginalJpeg);
}
I need to follow exactly these steps (cannot delete original file before opening TempImage.jpg). Can anybody help in knowing why copy and opening of temp file lock the original file. How can I prevent original jpeg file from being locked. I am new in .Net. Please help me.
More Info about the user case: The user case is that user cannot perform any operation on original file. So a temporary copy of original file is created in temp folder. User can then open/edit temp file. And if he thinks that he can replace original file with that of edited (copied in temp directory) one or he does not need original file any more, he can delete original file (and if required, can make temp file as the original one). So I strictly need to follow the same steps.
Regards
Aseem
Thanks in Advance
|
|
|
|
|
DO NOT cross post or repost you question.
You have received responses to your original post. Posting again will not allow others to see all the context and what has been tried already.
Read "How to get answers..." at the top of this forum!
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
|
You can't. THe image is represented in memory as a 32-bit full resolution bitmap in memory. In the file, it's compressed down to whatever the JPEG encoding settings are. For example, an image that is 3000x2000 pixels will take up 24MB of memory at full resolution. The resulting image on screen will not be that large, so it'll get painted scaled down to whatever size is visible. There is no class in the .NET Framework that will reduce the memory size by representing the image in its file format. You'd have to either write your own class to do this or find a 3rd party library that does this. I don't know of any.
|
|
|
|
|
if, I repeat: if, your PictureBox is significantly smaller than the original image, then you could solve your problem by creating a new and smaller image, like so:
Bitmap bm1=Bitmap.FromFile(filespec);
Bitmap bm2=new Bitmap(bm1, myPictureBox.Size);
bm1.Dispose();
myPictureBox.Image=bm2;
if not, there's nothing much you can do about it, as .NET keeps images in RAM as real bitmaps (normally 4B/px).
|
|
|
|
|
|
Probably because it implemented a custom class to represent the image in its native file format in memory. That would also mean it has to have custom rendering code to parse the image data, as needed, and only the sections of it that are required to render the visible part of the image on screen.
|
|
|
|
|
Hi,
Hope this is the right place to post this question. If not please let me know the right place.
I've an application in .net 3.5 framework. I would like to create a setup for the application, which will install the .net framework also(if it doesn't present in client machine). Please guide me how to achieve this. Thanks in advance.
|
|
|
|
|
YOu can use VS to create a setup program. It will automatically detect dependencies such as the .NET Framework and offers an option to include it with the setup or download it.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Thanks for your reply. I created setup project for the application and it detected .Net framework dependency automatically. But could you let me know where can I find the option to include framework so that it will install framework while installing the application. Thanks in advance
|
|
|
|
|
View the properties for the setup project then click the Prerequisites button
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
|
Navigate the given link to know how to deploy application along with .Net Framework
deployment guides[^] and click on this Link[^] to download The guide provides information on deploying all types of Framework application using a variety of mechanisms, including no-touch deployment, and Windows Installer package deployment.
Hope it will work for you.
|
|
|
|
|
MEMSG.To = GetData(tsqlemail)
the ERROR i get is: Property 'To' is 'ReadOnly'.
how do i correct this???
deepshikha
|
|
|
|
|
Hi,
which type is MEMSG from? Maybe there is a static method for the MEMSG-type to pass "To" to.
Regards
Sebastian
|
|
|
|
|
This means that there is no public setter for the To property. There will be another mechanism for adding the data, maybe via the constructor - unfortunately, without the 1000 mile telepathic link available, I have no idea what MEMSG is so can't tell you what this mechanism is.
|
|
|
|
|
Maybe this helps: in System.Net.Mail.MailMessage class, the recipient properties (To, Cc, Bcc) are collections, that cannot be set, however they can be operated upon, using methods such as Clear() and Add(). I suggest you read the documentation...
|
|
|
|
|
Luc Pattyn wrote: I suggest you read the documentation...
That's just too much trouble. It's much easier to ask then rant when no one understands or gives you the answer you want. Then it's their fault, not yours.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Sorry, I am aware I sometimes repeat myself.
|
|
|
|
|
I didn't catch that. Could you say it again?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I will. Someday. You'll notice I'm sure.
|
|
|
|
|
Dear friends,
as an Administrator I love the way Windows-ACLs do their work for us. The Framework does indeed support Access Control Lists but it has the lack of using them easily for your own custom objects. There are some functions that are not implemented in managed code, requiring that logic to be PInvoked, such as Inheritance-, Propagation-, Persistance- and AccessCheck-mechanisims.
I have started to implement that missing pieces by building an interface-based object model for the backend and a WPF-based Editor for the frontend looking like the Windows-Original.
I would like to initiate an article / project about that if - and here comes my questions in place - there is a general interest from your side.
So if you are interested in that matter or (even better) would like to support it, please post me an answer here on codeproject or just send me an eMail.
Greetings,
Tobias
modified on Thursday, September 2, 2010 12:42 PM
|
|
|
|
|
Asking what the interest is doesn't quite work. Your post will only be seen by a small number of people. Don't try and find the interested people.
Just write the article, let the search engine crawlers find it and, eventually, interested people using Google, Bing, and Yahoo, will find you.
|
|
|
|
|