Click here to Skip to main content
15,881,559 members
Home / Discussions / C#
   

C#

 
GeneralRe: VB To C# ( _value = Asc(Mid(LStr, IValue, 1))) Pin
Pete O'Hanlon24-Sep-12 23:29
mvePete O'Hanlon24-Sep-12 23:29 
AnswerRe: VB To C# ( _value = Asc(Mid(LStr, IValue, 1))) Pin
BobJanova24-Sep-12 23:53
BobJanova24-Sep-12 23:53 
AnswerRe: VB To C# ( _value = Asc(Mid(LStr, IValue, 1))) Pin
Dave Doknjas25-Sep-12 14:13
Dave Doknjas25-Sep-12 14:13 
GeneralRe: VB To C# ( _value = Asc(Mid(LStr, IValue, 1))) Pin
Pete O'Hanlon25-Sep-12 20:57
mvePete O'Hanlon25-Sep-12 20:57 
QuestionReading data from mobilephone througe usb port Pin
sreejeshn24-Sep-12 21:59
sreejeshn24-Sep-12 21:59 
AnswerRe: Reading data from mobilephone througe usb port Pin
Eddy Vluggen25-Sep-12 0:19
professionalEddy Vluggen25-Sep-12 0:19 
QuestionDeserialize Pin
Member 928312224-Sep-12 17:44
Member 928312224-Sep-12 17:44 
QuestionC# can not locate file Pin
rachel_m24-Sep-12 17:42
rachel_m24-Sep-12 17: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 21:04
Abhinav S24-Sep-12 21:04 
AnswerRe: C# can not locate file Pin
Richard MacCutchan24-Sep-12 22:01
mveRichard MacCutchan24-Sep-12 22:01 
GeneralRe: C# can not locate file Pin
Alan N25-Sep-12 0:42
Alan N25-Sep-12 0:42 
GeneralRe: C# can not locate file Pin
Richard MacCutchan25-Sep-12 5:43
mveRichard MacCutchan25-Sep-12 5:43 
AnswerRe: C# can not locate file Pin
jschell25-Sep-12 8:34
jschell25-Sep-12 8:34 
QuestionShould i use my DAL in my acceptance tests? Pin
Member 867449224-Sep-12 12:34
Member 867449224-Sep-12 12:34 
AnswerRe: Should i use my DAL in my acceptance tests? Pin
jschell24-Sep-12 12:42
jschell24-Sep-12 12:42 
AnswerRe: Should i use my DAL in my acceptance tests? Pin
V.24-Sep-12 20:16
professionalV.24-Sep-12 20:16 
AnswerRe: Should i use my DAL in my acceptance tests? Pin
BobJanova24-Sep-12 23:54
BobJanova24-Sep-12 23:54 
AnswerRe: Should i use my DAL in my acceptance tests? Pin
Pete O'Hanlon25-Sep-12 0:42
mvePete O'Hanlon25-Sep-12 0:42 
Questionftp download Pin
Member 945456324-Sep-12 5:04
Member 945456324-Sep-12 5:04 
AnswerRe: ftp download Pin
Pete O'Hanlon24-Sep-12 5:09
mvePete O'Hanlon24-Sep-12 5:09 
AnswerRe: ftp download Pin
Eddy Vluggen24-Sep-12 5:16
professionalEddy Vluggen24-Sep-12 5:16 
QuestionASAP Pin
rikah23-Sep-12 21:15
rikah23-Sep-12 21:15 
AnswerRe: ASAP Pin
Ingo23-Sep-12 21:53
Ingo23-Sep-12 21:53 
AnswerRe: ASAP Pin
Ravi Bhavnani24-Sep-12 4:17
professionalRavi Bhavnani24-Sep-12 4:17 
GeneralRe: ASAP Pin
rikah3-Oct-12 1:29
rikah3-Oct-12 1: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.