Click here to Skip to main content
15,897,273 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: how can i take only month from datetime variable Pin
Lijo Rajan28-Oct-07 22:36
Lijo Rajan28-Oct-07 22:36 
GeneralRe: how can i take only month from datetime variable Pin
Harun_asp.net28-Oct-07 23:28
Harun_asp.net28-Oct-07 23:28 
Answerhow can i take only month from datetime variable Pin
Sarani Ravindran28-Oct-07 22:40
Sarani Ravindran28-Oct-07 22:40 
AnswerRe: how can i take only month from datetime variable Pin
N a v a n e e t h28-Oct-07 22:44
N a v a n e e t h28-Oct-07 22:44 
Questionhyperlink column in gridview Pin
Sunil Wise28-Oct-07 21:49
professionalSunil Wise28-Oct-07 21:49 
AnswerRe: hyperlink column in gridview Pin
Imran Khan Pathan28-Oct-07 23:14
Imran Khan Pathan28-Oct-07 23:14 
GeneralRe: hyperlink column in gridview Pin
Sunil Wise29-Oct-07 0:25
professionalSunil Wise29-Oct-07 0:25 
QuestionImages delete. Pin
jai 12328-Oct-07 21:45
jai 12328-Oct-07 21:45 
hi,
I am using the below coding to thumbnail creation, this coding is saving both the original image and the thumbnail image. I don’t want the original image. How to delete the original image. Please help me.


private void btnUpload_Click(object sender, System.EventArgs e)
{
// Initialize variables
string sSavePath;
string sThumbExtension;
int intThumbWidth;
int intThumbHeight;

// Set constant values
sSavePath = "images/";
sThumbExtension = "_thumb";
intThumbWidth = 160;
intThumbHeight = 120;

// If file field isn’t empty
if (filUpload.PostedFile != null)
{
// Check file size (mustn’t be 0)
HttpPostedFile myFile = filUpload.PostedFile;
int nFileLen = myFile.ContentLength;
if (nFileLen == 0)
{
lblOutput.Text = "No file was uploaded.";
return;
}

// Check file extension (must be JPG)
if (System.IO.Path.GetExtension(myFile.FileName).ToLower() != ".jpg")
{
lblOutput.Text = "The file must have an extension of JPG";
return;
}

// Read file into a data stream
byte[] myData = new Byte[nFileLen];
myFile.InputStream.Read(myData,0,nFileLen);

// Make sure a duplicate file doesn’t exist. If it does, keep on appending an
// incremental numeric until it is unique
string sFilename = System.IO.Path.GetFileName(myFile.FileName);
int file_append = 0;
while (System.IO.File.Exists(Server.MapPath(sSavePath + sFilename)))
{
file_append++;
sFilename = System.IO.Path.GetFileNameWithoutExtension(myFile.FileName)
+ file_append.ToString() + ".jpg";
}

// Save the stream to disk
System.IO.FileStream newFile
= new System.IO.FileStream(Server.MapPath(sSavePath + sFilename),
System.IO.FileMode.Create);
newFile.Write(myData,0, myData.Length);
newFile.Close();

// Check whether the file is really a JPEG by opening it
System.Drawing.Image.GetThumbnailImageAbort myCallBack =
new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);
Bitmap myBitmap;
try
{
myBitmap = new Bitmap(Server.MapPath(sSavePath + sFilename));

// If jpg file is a jpeg, create a thumbnail filename that is unique.
file_append = 0;
string sThumbFile = System.IO.Path.GetFileNameWithoutExtension(myFile.FileName)
+ sThumbExtension + ".jpg";
while (System.IO.File.Exists(Server.MapPath(sSavePath + sThumbFile)))
{
file_append++;
sThumbFile = System.IO.Path.GetFileNameWithoutExtension(myFile.FileName) +
file_append.ToString() + sThumbExtension + ".jpg";
}

// Save thumbnail and output it onto the webpage
System.Drawing.Image myThumbnail
= myBitmap.GetThumbnailImage(intThumbWidth,
intThumbHeight, myCallBack, IntPtr.Zero);
myThumbnail.Save (Server.MapPath(sSavePath + sThumbFile));
imgPicture.ImageUrl = sSavePath + sThumbFile;

// Displaying success information
lblOutput.Text = "File uploaded successfully!";

// Destroy objects
myThumbnail.Dispose();
myBitmap.Dispose();
}
catch (ArgumentException errArgument)
{
// The file wasn't a valid jpg file
lblOutput.Text = "The file wasn't a valid jpg file.";
System.IO.File.Delete(Server.MapPath(sSavePath + sFilename));
}
}
}

public bool ThumbnailCallback()
{
return false;
}


prakash

AnswerRe: Images delete. Pin
Guffa28-Oct-07 23:01
Guffa28-Oct-07 23:01 
QuestionDifference between ASP.NET 1.x and 2.x Pin
Khan.Bangash28-Oct-07 21:44
Khan.Bangash28-Oct-07 21:44 
QuestionHow to make datareport enable online which r smoothly working at localhost in asp.net?? Pin
BeBadgujar28-Oct-07 21:09
BeBadgujar28-Oct-07 21:09 
QuestionLogin control and roles Pin
G.K.M.28-Oct-07 21:02
G.K.M.28-Oct-07 21:02 
QuestionRedirect from https to http Pin
Prakash_Mishra28-Oct-07 20:49
Prakash_Mishra28-Oct-07 20:49 
AnswerRe: Redirect from https to http Pin
N a v a n e e t h28-Oct-07 21:11
N a v a n e e t h28-Oct-07 21:11 
GeneralRe: Redirect from https to http Pin
Prakash_Mishra28-Oct-07 22:10
Prakash_Mishra28-Oct-07 22:10 
AnswerRe: Redirect from https to http Pin
Ghazi H. Wadi28-Oct-07 21:19
Ghazi H. Wadi28-Oct-07 21:19 
GeneralRe: Redirect from https to http Pin
Prakash_Mishra28-Oct-07 22:09
Prakash_Mishra28-Oct-07 22:09 
Questiondatagrid doubt Pin
saravanan0528-Oct-07 20:49
saravanan0528-Oct-07 20:49 
AnswerRe: datagrid doubt Pin
soni uma28-Oct-07 20:58
soni uma28-Oct-07 20:58 
AnswerRe: datagrid doubt Pin
N a v a n e e t h28-Oct-07 20:58
N a v a n e e t h28-Oct-07 20:58 
AnswerRe: datagrid doubt Pin
Lijo Rajan28-Oct-07 20:59
Lijo Rajan28-Oct-07 20:59 
GeneralRe: datagrid doubt Pin
saravanan0528-Oct-07 21:15
saravanan0528-Oct-07 21:15 
GeneralRe: datagrid doubt Pin
Lijo Rajan28-Oct-07 21:25
Lijo Rajan28-Oct-07 21:25 
QuestionDatabase support for a website Pin
niting8528-Oct-07 20:44
niting8528-Oct-07 20:44 
AnswerRe: Database support for a website Pin
John-ph28-Oct-07 21:46
John-ph28-Oct-07 21:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.