Click here to Skip to main content
15,886,919 members
Home / Discussions / C#
   

C#

 
QuestionAndroid Studio: How can disable My applications in mobile when i run my application? Pin
Dr Kasa10-Oct-16 3:54
Dr Kasa10-Oct-16 3:54 
AnswerRe: Android Studio: How can disable My applications in mobile when i run my application? Pin
Pete O'Hanlon10-Oct-16 4:11
mvePete O'Hanlon10-Oct-16 4:11 
AnswerRe: Android Studio: How can disable My applications in mobile when i run my application? Pin
OriginalGriff10-Oct-16 4:11
mveOriginalGriff10-Oct-16 4:11 
GeneralRe: Android Studio: How can disable My applications in mobile when i run my application? Pin
Eddy Vluggen10-Oct-16 4:38
professionalEddy Vluggen10-Oct-16 4:38 
GeneralRe: Android Studio: How can disable My applications in mobile when i run my application? Pin
OriginalGriff10-Oct-16 4:42
mveOriginalGriff10-Oct-16 4:42 
GeneralRe: Android Studio: How can disable My applications in mobile when i run my application? Pin
Eddy Vluggen10-Oct-16 5:02
professionalEddy Vluggen10-Oct-16 5:02 
GeneralRe: Android Studio: How can disable My applications in mobile when i run my application? Pin
OriginalGriff10-Oct-16 5:53
mveOriginalGriff10-Oct-16 5:53 
QuestionLong Path Exception when adding attachments Pin
NJdotnetdev10-Oct-16 3:00
NJdotnetdev10-Oct-16 3:00 
I am getting a long path exception while adding attachments to MailMessage. Our file path exceeds 260, but that's how it is and we want it to work.

Following is what I have done to avoid the exception:
C#
private void CreateAttachments(MailMessage mailMessage, List<string> filesToAdd)
        {
            foreach (string fileToAdd in filesToAdd)
            {
                SafeFileHandle fileHandle = null;
                try
                {
                    fileHandle = Common.CreateFile(Common.prefixPath(fileToAdd), Common.GENERIC_READ, FileShare.Read, IntPtr.Zero, FileMode.Open, 0, IntPtr.Zero);
                    if (!fileHandle.IsInvalid)
                    {
                        using (FileStream fs = new FileStream(fileHandle, FileAccess.Read))
                        {
                            Attachment data = new Attachment(fs, fileToAdd);
                            mailMessage.Attachments.Add(data);
                        }
                    }
                }
                finally
                {
                    if ((fileHandle != null) || fileHandle.IsInvalid)
                        fileHandle.Dispose();
                }
            }
        }


Above LOC doesn't throw an exception while adding attachments. But, while sending(smtpClient.Send(mailMessage)) it throws an exception "Failure Sending Mail".

UPDATED CODE

modified 10-Oct-16 10:17am.

AnswerRe: Long Path Exception when adding attachments Pin
F-ES Sitecore10-Oct-16 3:16
professionalF-ES Sitecore10-Oct-16 3:16 
AnswerRe: Long Path Exception when adding attachments Pin
NJdotnetdev12-Oct-16 4:35
NJdotnetdev12-Oct-16 4:35 
GeneralRe: Long Path Exception when adding attachments Pin
Eddy Vluggen12-Oct-16 7:03
professionalEddy Vluggen12-Oct-16 7:03 
GeneralRe: Long Path Exception when adding attachments Pin
NJdotnetdev17-Oct-16 2:23
NJdotnetdev17-Oct-16 2:23 
Questionan "injection" problem/challenge Pin
BillWoodruff9-Oct-16 22:45
professionalBillWoodruff9-Oct-16 22:45 
AnswerRe: an "injection" problem/challenge Pin
Richard Deeming10-Oct-16 3:21
mveRichard Deeming10-Oct-16 3:21 
GeneralRe: an "injection" problem/challenge Pin
BillWoodruff10-Oct-16 4:56
professionalBillWoodruff10-Oct-16 4:56 
Questionhow to read mbr Pin
Member 124586219-Oct-16 2:00
Member 124586219-Oct-16 2:00 
AnswerRe: how to read mbr Pin
NotPolitcallyCorrect9-Oct-16 2:19
NotPolitcallyCorrect9-Oct-16 2:19 
AnswerRe: how to read mbr Pin
OriginalGriff9-Oct-16 2:24
mveOriginalGriff9-Oct-16 2:24 
QuestionResistor color code Pin
Pavlex48-Oct-16 23:34
Pavlex48-Oct-16 23:34 
AnswerRe: Resistor color code Pin
Jochen Arndt9-Oct-16 0:44
professionalJochen Arndt9-Oct-16 0:44 
GeneralRe: Resistor color code Pin
Pavlex49-Oct-16 0:48
Pavlex49-Oct-16 0:48 
GeneralRe: Resistor color code Pin
Jochen Arndt9-Oct-16 1:09
professionalJochen Arndt9-Oct-16 1:09 
GeneralRe: Resistor color code Pin
Pavlex49-Oct-16 1:11
Pavlex49-Oct-16 1:11 
GeneralRe: Resistor color code Pin
Pavlex49-Oct-16 7:31
Pavlex49-Oct-16 7:31 
GeneralRe: Resistor color code Pin
Pavlex49-Oct-16 12:21
Pavlex49-Oct-16 12:21 

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.