Click here to Skip to main content
15,122,149 members
Home / Discussions / C#
   

C#

 
GeneralRe: VB To C# ( _value = Asc(Mid(LStr, IValue, 1))) Pin
Pete O'Hanlon25-Sep-12 0:29
mvePete O'Hanlon25-Sep-12 0:29 
AnswerRe: VB To C# ( _value = Asc(Mid(LStr, IValue, 1))) Pin
BobJanova25-Sep-12 0:53
MemberBobJanova25-Sep-12 0:53 
AnswerRe: VB To C# ( _value = Asc(Mid(LStr, IValue, 1))) Pin
Dave Doknjas25-Sep-12 15:13
MemberDave Doknjas25-Sep-12 15:13 
GeneralRe: VB To C# ( _value = Asc(Mid(LStr, IValue, 1))) Pin
Pete O'Hanlon25-Sep-12 21:57
mvePete O'Hanlon25-Sep-12 21:57 
QuestionReading data from mobilephone througe usb port Pin
sreejeshn24-Sep-12 22:59
Membersreejeshn24-Sep-12 22:59 
AnswerRe: Reading data from mobilephone througe usb port Pin
Eddy Vluggen25-Sep-12 1:19
professionalEddy Vluggen25-Sep-12 1:19 
QuestionDeserialize Pin
Member 928312224-Sep-12 18:44
MemberMember 928312224-Sep-12 18:44 
QuestionC# can not locate file Pin
rachel_m24-Sep-12 18:42
Memberrachel_m24-Sep-12 18:42 
In a C# 2008 application, the code listed below ends up in the catch exception block. The error message says the file can not be
located in the specified location: "C://temp//09-24-2012//companyname_company.xlsx".
The value for the String fileName in the createCust is obtained from the value passed
to this method. The file does exist on the specified location.

The code I am referring to is listed below:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common.Logging;
using System.IO;

namespace sample1
{
    public class Helper1
    {
        private static ILog log = LogManager.GetCurrentClassLogger();

        public Customer createCust(String CustId, String fileName)
        {

            Customer cst = new Customer();
            byte[] buffer = null;
            try
            {
                
                System.IO.FileStream fileStream = new System.IO.FileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);

                System.IO.BinaryReader binaryReader = new System.IO.BinaryReader(fileStream);

                long totalBytes = new System.IO.FileInfo(fileName).Length;

                buffer = binaryReader.ReadBytes((Int32)totalBytes);

                DateTime attachmentId = DateTime.Now;
                cst.Id = attachmentId.ToString();
                cst.MimeType = getMimeType(fileName);
                cst.Value = buffer;
                fileStream.Close();
                binaryReader.Close();
            }
            catch (Exception e)
            {

                throw new Exception(e.Message);
            }

            return cust;
        }
}}

I do not have any idea of why the file can not be located. The file exists in the path
that is passed to the createCust method. The location of the file path is specified as,
"C://temp//09-24-2012//companyname_company.xlsx".

Thus can you tell me what could be causing the file not to be located and how to fix the problem?
AnswerRe: C# can not locate file Pin
Abhinav S24-Sep-12 22:04
MemberAbhinav S24-Sep-12 22:04 
AnswerRe: C# can not locate file Pin
Richard MacCutchan24-Sep-12 23:01
mveRichard MacCutchan24-Sep-12 23:01 
GeneralRe: C# can not locate file Pin
Alan N25-Sep-12 1:42
MemberAlan N25-Sep-12 1:42 
GeneralRe: C# can not locate file Pin
Richard MacCutchan25-Sep-12 6:43
mveRichard MacCutchan25-Sep-12 6:43 
AnswerRe: C# can not locate file Pin
jschell25-Sep-12 9:34
Memberjschell25-Sep-12 9:34 
QuestionShould i use my DAL in my acceptance tests? Pin
Member 867449224-Sep-12 13:34
MemberMember 867449224-Sep-12 13:34 
AnswerRe: Should i use my DAL in my acceptance tests? Pin
jschell24-Sep-12 13:42
Memberjschell24-Sep-12 13:42 
AnswerRe: Should i use my DAL in my acceptance tests? Pin
V.24-Sep-12 21:16
professionalV.24-Sep-12 21:16 
AnswerRe: Should i use my DAL in my acceptance tests? Pin
BobJanova25-Sep-12 0:54
MemberBobJanova25-Sep-12 0:54 
AnswerRe: Should i use my DAL in my acceptance tests? Pin
Pete O'Hanlon25-Sep-12 1:42
mvePete O'Hanlon25-Sep-12 1:42 
Questionftp download Pin
Member 945456324-Sep-12 6:04
MemberMember 945456324-Sep-12 6:04 
AnswerRe: ftp download Pin
Pete O'Hanlon24-Sep-12 6:09
mvePete O'Hanlon24-Sep-12 6:09 
AnswerRe: ftp download Pin
Eddy Vluggen24-Sep-12 6:16
professionalEddy Vluggen24-Sep-12 6:16 
QuestionASAP Pin
rikah23-Sep-12 22:15
Memberrikah23-Sep-12 22:15 
AnswerRe: ASAP Pin
Ingo23-Sep-12 22:53
MemberIngo23-Sep-12 22:53 
AnswerRe: ASAP Pin
Ravi Bhavnani24-Sep-12 5:17
professionalRavi Bhavnani24-Sep-12 5:17 
GeneralRe: ASAP Pin
rikah3-Oct-12 2:29
Memberrikah3-Oct-12 2:29 

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.