I have a method that creates this value:
It is stored in the DB as <Binary Data>.
I use Select value from table where id = 1234.
This is the code that writes creates the value:
public void SetSessionData(string token, object data)
DataService ds = null;
ds = new DataService();
using (MemoryStream stream = new MemoryStream())
DALArgs args = new DALArgs();
BinaryFormatter b = new BinaryFormatter();
stream.Position = 0;
byte buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);
I'm trying to figure out how I can assign the results of the select statement to a variable and create this response:
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:
public class Helper1
private static ILog log = LogManager.GetCurrentClassLogger();
public Customer createCust(String CustId, String fileName)
Customer cst = new Customer();
byte buffer = null;
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;
catch (Exception e)
throw new Exception(e.Message);
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,
Thus can you tell me what could be causing the file not to be located and how to fix the problem?
True for the Windows API but not for the .NET System.IO classes which will accept either flavour of path separator. The redundant 'escaping' in the forward slashed path string is also gracefully ignored.
I'm currently doing Automated Acceptance test driven development, and I'm wondering if I should use my real Data Access Layer in my tests, or if I should fake out the data instead and just verify that what is being passed to/from is correct.
One issue is that the DAL is being developed by another team, and i'm coding the front end/business logic. I could make it work so I could test the real thing, but i'm not sure.
Most decent mocking toolkits will allow you to simulate return values from code, so you could call your DAL code and set it up to ignore certain calls and then return you carefully crafted data to satisfy your test criteria.
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
Please help me to do a program that can download a file from a ftpserver with a progress bar that computes the percentage of the downloaded data. But it is by using the asynchronous method that was written from the codefile.cs and that will be called on th form.cs.The progress bar is in the other form.t.y
that can download a file from a ftpserver with a progress bar that computes the percentage of the downloaded data. But it is by using the asynchronous method that was written from the codefile.cs and that will be called on th form.cs.The progress bar is in the other form
What do you need help with exactly? Finding the manual? Well, here[^] it is, and even contains samples. Anything else you need help with?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
On the windows form, we put listbox for the list of directories. A button to get the list of directories and display it on the listbox. Another button for downloading, and another button for uploading. We just need Asynchronous method when downloading or uploading a file or getting the list of directories.
I have a small project that would require me to convert a ASP Classic with 5000+ lines of code to ASP .NET C# is there such a tool that can do this for me? I've already research for the whole week but all the tools that I've tried didn't work. should I do a rewrite for the whole thing?
I don't believe there is any tool that can do a full conversion for you.
There are a few that can help you convert parts of the program but honestly, you will have to do a large amount of conversion on your own.
I have a program that reads stuff from a Searial COM port. It uses one of those USB to COM port gizmos (Prolific driver).
The environment is Win7/Server 2008R2 (all 64 bit), joined to domain, .NET4.
The program works fine when run from within context of an end user.
However, when i try to run the same program as a windows service I get 'The system cannot find the file specified'. I tried to configure the service to run both as a local system account and as a domain service account (added to the admin ug), but still the same error.
I also created a little test program (see the code at the end of the post, it is stolen from somewhere on the internet).
This runs fine when run from the console and opens the port and reports its type (CHAR), but fails with the same error (File not found) when i try to run it as a scheduled job.
Again i tried running it both under my own account and under account of a service (both added as local admins) and it is the same error.
I am pretty sure it is some sort of a security/policy issue but cannot quite figure out what.
Any pointers will be greatly appreciated,
staticvoid Main(string args)
var portName = @"\\.\COM3";
var handle = CreateFile(portName, 0, 0, IntPtr.Zero, 3, 0x80, IntPtr.Zero);
if (handle == (IntPtr)(-1))
Console.WriteLine("Could not open " + portName + ": "
+ new Win32Exception().Message);
var type = GetFileType(handle);
Console.WriteLine("File " + portName + " reports its type as: " + type);
[DllImport("kernel32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall,
SetLastError = true)]
staticextern FileType GetFileType(IntPtr hFile);
enum FileType : uint
UNKNOWN = 0x0000,
DISK = 0x0001,
CHAR = 0x0002,
PIPE = 0x0003,
REMOTE = 0x8000,
Last Visit: 31-Dec-99 18:00 Last Update: 20-Sep-21 5:35