.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Sharon Maxwell
Post New Web Links

reading some strange file

Posted By:      Posted Date: August 28, 2010    Points: 0   Category :.NET Framework
 
hi all,I have a file that i want to read created by a program from another company.I fi open the file in notepad it has all kind of funny chars in it, i tried different ways of reading it in vb.net but the funny chars stay.Anyone has any idea how to read something like this?this is an extract from the file  Z "f 2006/05/19 13:44:28 < ----------- uStreetname 91 1745 Opwijk                                                                                  ' 590208356329 SLIN3f )lÿ%g: )' 29.11.2005grtz & thnx to anyone who looked into this.bjorn


View Complete Post


More Related Resource Links

reading TXT file with (èàò) and return strange character

  
  Private Function Traduci(ByVal file As String)

    Dim testo As String = My.Computer.FileSystem.ReadAllText(file)

    Dim righe As String()
    righe = Split(testo, vbCrLf)

    For i As Integer = 0 To righe.Length - 1
      Debug.Print(testo)
    Next

  End Function<br/>

i am trying to read an TXT fiel with this function
in my example.txt i have this row:"pèpòàèpòàpèòp+p"

but the program returns": p?p???p??p??p+p"
is the charset the problem? if yes where can i set it?


hi

reading excel file problem

  

Hi,


i have 200 rows in my excel file. im using OleDbConnection to read the excel file.

The problem is that it will read all the blank rows from row 200 onwards. Is there a configuration im missing ? or is there a way to import all rows that has data? Here's some of my code.


string excelConnectionString =
               "Provider=Microsoft.Jet.OLEDB.4.0;" +
                "Data Source=" + filePath + ";" +
                "Extended Properties=Excel 8.0";

OleDbConnection excelConnection =
                    new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";Extended Properties='Excel 8.0;HDR=NO'");


OleDbCommand cmd = new OleDbCommand("Select * from [list$]",excelConnection);







Reading an excel file

  

Hi,

i am trying to read an excel file.

when i read the entire file, it works fine.

but when i try to read a single column, i get the following exception message:

"Could not find installable ISAM".

the code i am using is:

string  connString = "Provider=Microsoft.ACE.OLEDB.12.0;" +  

 

"Data Source="+ fileName + ";" +

 

"Extended Properties=Excel 12.0;HDR=Yes";

OleDbConnection oledbConn = new OleDbConnection(connString);

 

try

{

// Open connection

oledbConn.Open();

 

// Create OleDbCommand object and select data from worksheet Sheet1

OleDbCommand cmd = new OleDbCommand

Problem when using Activator.CreateObject and reading App.Config file

  
Hello, this is the scenario. I have an application that load at runtime severals dll. these dll are actually "adapters" that wraps calls to web services, database and so on. The app.config of the "main" application stores in config sections all information necessary to each adapter (i.e.Web ServiceURL..) and I have created inside each adapter a class to ready those values the loading at run time the DLL has been implemented by storing all necessary types into a dictionary of generics and when I need to instanciate it I call the Activate.CreateObject and I pass the specific type (I means the name of the Adapter class) The problem is that the adapter class itself is not able to get the config value because ConfigSection has not been initialized. If I write: IInterfaceAdap adapt = new myAdapter() -> I read the config data IInterfaceAdap adapt = (IInterfaceAdap)Activator.CreateObject (type) -> now way to read the data stored in the App.Config. I think that I undertood the problem but I'm not able to find a workaround to read data store in the app.config!! I need help please!!  

reading excel file without saving to disk first

  
Having an issue.  I need to be able to read an excel file from a file upload control but I can not save the file to disk first, it must be done in memory.string excelConnectionstring = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="; excelConnectionstring += filePath.Replace("/", "\\"); excelConnectionstring += ";Extended Properties='Excel 8.0;HDR=YES;IMEX=1;'"; OleDbConnection con = new OleDbConnection(excelConnectionstring); OleDbDataAdapter da = new OleDbDataAdapter();Above is my code for reading the data file if it IS saved to disk, but again, I have to be able to do this without saving the file to disk, it must be done in memory.  I have not been able to find any sample code anywhere on how to do this from memory, everything seems to force the file be uploaded, saved to disk, and then read in the connection string, which again I can not do.Any advise would be great, thanks in advance.  I'm really in a bind here.

Error reading .config file in Windows Forms app - Access is denied

  
I'm attempting to read a connection string from a .config file in a Windows Forms app on a test laptop. A previous version of the application worked just fine, but now I get a configuration exception thrown - "Configuration system failed to initialize." The inner exception message says - "An error occurred loading a configuration file: Access is denied". The user I'm logged in as is in the Administrators group and there's no obvious problems with the config file. The same config file works just fine on my dev machine so it's not an issue with ordering of the XML. Any ideas would be greatly appreciated.If a response to your question is helpful or answers it please mark it as such!

Error reading .config file in Windows Forms app - Access is denied

  
I'm attempting to read a connection string from a .config file in a Windows Forms app on a test laptop. A previous version of the application worked just fine, but now I get a configuration exception thrown - "Configuration system failed to initialize." The inner exception message says - "An error occurred loading a configuration file: Access is denied". The user I'm logged in as is in the Administrators group and there's no obvious problems with the config file. The same config file works just fine on my dev machine so it's not an issue with ordering of the XML. Any ideas would be greatly appreciated.If a response to your question is helpful or answers it please mark it as such!

Strange characters exporting a blob file using bcp

  
Hi, I am trying to insert and export a binary file into SQL 2005. I need that word, pdf and txt file work. I can't use file path and this is the only choice I have. I am using this way: 1) Create a file test.txt and write "hello" into it. 2) CREATE TABLE [dbo].[myfiles]( [file] [varbinary](max) NOT NULL) ON Primary 3) INSERT INTO [myfiles]([file]) SELECT BulkColumn FROM OPENROWSET ( BULK 'C:\test.txt', SINGLE_BLOB) AS BinFile 4) declare @SQLcommand nvarchar(4000) set @SQLcommand =       'bcp "SELECT top 1 [file] FROM myfiles" queryout "c: \temp\test.txt" -T -n -SMYPC' exec xp_cmdshell @SQLcommand When I open file c:\temp\test.txt I can see strange characters before "hello" Trying to insert a word file says me that the file is corrupted. How can I solve this ? Thanks.

Reading each record from a text file and sending email

  
Hi All, I have a text file (CSV) which has only three fields (Name, Email, SendYN). I want to read each record from this text file and send email to those records where SendYN field has Y. I had created Flat File connection and a Flat File source in a data flow which uses Flat file connection. Now I stuck how to move further. Which control I need to add and where to identify whether SenderYN = Y and how to send email? I am new to SSIS. Thanks.

Reading from Excel file : win form

  
Hi All, I have the following requirement  There are 10 Excel files in a folder.Each excel file contains only 1 column which contains severeal IDs listed. Now, I want to read those IDs in each & every excel file. How do I get the count of number of excel files present in that folder?? After getting the count, how do I read each Id present in that file?? Any help will be greatly apprecited.. Thanks, Alex

WCF Reading Endpoint Behaviors from a web.config file

  

Hi

I've got a WCF service which has multiple clients that it connects to.

What I want to do is to create the clients dynamically the WCF services consumes.

Creating the clients by inheriting from the `ServiceFactory<TChannel>` class is done and very simple. What I'm struggling with is how to read Endpoint behaviours from the `web.config` file and add them to the clients?

Code file

    BasicHttpBinding binding = new BasicHttpBinding(bindingConfigName);
    EndpointAddress endpoint = new EndpointAddress(endpointUrl);
    ChannelFactory<IShoppingSoap> clientEndpoint = new ChannelFactory<IShoppingSoap>(binding, endpoint);
   
    base.Endpoint.Behaviors.Add(*Get the behavior from the config file*);
    return base.CreateChannel();

`Web.config` file :

    <behaviors> 
        <endpointBehaviors> 
           <behavior name="EndpointBehaviour_GmCustom">
             <dataContractSerializer maxItemsInObjectGraph="2147483646" /> 
      

Reading in values in text file in a project solution to an array

  

Hi,

I have a tab delimited text file that has 6 columns (all integers) and 500 rows (and no column headings) called ProjectData.txt that I have added to my Windows Form Application (c#) (by added I mean I have it in my project solution). 

I have declared an array in my code called ProjectDataArray which has dimensions [500, 6].

I wish to load each column of each row into the array.

All the code I have seen shows how to do this for text files that are not included in the project solution. 

Is this easy to do?


reading text file using sql server 2000 , 2008

  

hi,

can any one tell me how to read the data's in the text file using sql server 2000 and 2008.

i have a text file in a server and it contains one column name with the multiple column values i need to read that informations and i need to update in a table in the database.

how can we do this.

Regards,

lawmen



Reading Binary file

  

Hi All, 

 I am using BinaryReader class to read binary file.But I am facing problem while reading number of  bytes from it.

I have written code to read only 2 bytes from it,it works well on my machine and read only 2 bytes,but when I deployed that code on server machine it read 4 bytes from file.Whats wrong in the code?Is it due to processor i.e.. 32 bit processor/64 bit processor I am using?

Please provide solution or any link for it ASAP..

Thanks in advance

Vaibhav

 

 


Reading strings from a binary file

  

I am tasked with reading various files that were saved to disk by a Visual Basic 4 application.

I've started with the easiest of the files, which contains one or more strings, each 128 bytes in length.

And so I wrote the following code to put these strings in a list:

 

Console.WriteLine("========== START ==========");

var list = new List<string>();

var fileStream = new FileStream("(Filename)", FileMode.Open);
	
var bytes = new byte[128];
while (true) {
 if (fileStream.Read(bytes, 0, bytes.Length) == 0) break;
 list.Add(System.Text.Encoding.ASCII.GetString(bytes));
}

foreach (var s in list) Console.WriteLine(s);

fileStream.Close();

Console.WriteLine("========== END ==========")

Reading and checking .CSV File and Inserting Data to SQL server

  

Hi,

I have got a page in which there is a file upload option where I have to upload/import the csv file. What I want to do is to check if the correct format of file is uploaded for instance if any other than csv file is uploaded, the system should give an error message. Also what I need to do is to check certain fields of the csv file for instance there are some mandatory fields in the csv file which should be there like name , postcode, How can I check that these fields are not empty . After performing these task, the system should automatically upload the csv file onto the sql sever 2008. Any ideas  or tutorial ... will be highly appreciated. 


Opening file causes strange message

  

when I save the file that is returned by Handler and try to open it I get the following message:"The file you trying to open, 'Users.xls', is in a different format than specified by the file extension. Verify that the file is not corrupt and is from a trusted source before opening the file. Do you want to open the file now?"

How to fix this?

Here the code of the handler:

using System.Web;
using System.Web.Services;
using System.IO;
using System.Data;
using System.Web.UI.WebControls;
using System.Web.UI;
using System.Text;

namespace WebApplication1
{
    public class Handler2 : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            string query = "SELECT FirstName, LastName, Email, Phone FROM tblUser WHERE IsSubscribed = 1";
            // As QueryDataSql = New QueryDataSql(query)

            DataTable dt = new DataTable();
            GridView gv = new GridView();

            dt.Columns.Add("FirstName");
            dt.Columns.Add("LastName");
            dt.Columns.Add("Email");
            dt.Columns.Add("Phone");


            DataRow dr = dt.NewRow();
            dr["First
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend