.NET FtpWebRequest Not Returning DateTimeStamp Or FileSize?

Jun 4, 2010

I'm using FtpWebRequest to connect to an FTP server and I can use WebRequestMethods.Ftp.ListDirectoryDetails to list the directory details fine. However the response from the remote server has day, month and time but not year:

-rw-rw-rw- 1 user group 949 Jun 2 08:43 Unsubscribes_20100602.zip
-rw-rw-rw- 1 user group 1773 Jun 1 06:48 export_142571709.txt
-rw-rw-rw- 1 user group 1773 Jun 1 06:50 export_142571722.txt
-rw-rw-rw- 1 user group 980 Jun 1 06:51 export_142571734.txt

This is required for the application I'm writing so I tried to use WebRequestMethods.Ftp.GetDateTimestamp to get the datetimestamp for each file but the response is always empty. No exception is thrown.

try
{
FtpWebRequest ftp = (FtpWebRequest)WebRequest.Create(path);
ftp.Credentials = new NetworkCredential(_ftpUsername, _ftpPassword);
ftp.Method = WebRequestMethods.Ftp.GetDateTimestamp;
try
{
Stream stream = ftp.GetResponse().GetResponseStream();
StreamReader sReader = new StreamReader(stream);
return sReader;
}
catch (Exception exp)
{
throw new Exception(String.Format("An error occured getting the timestamp for {0}: {1}<br />", path, exp.Message));
}
}

View 1 Replies


Similar Messages:

Web Forms :: Max Filesize For File Upload Control?

Dec 24, 2010

I am creating page for uploading video file to the server.

bydefault file upload limit set by asp.net is 20MB.

if user select more than 20MB application creating problem and showing "connection was reset"

I want to check file size before upload.

View 4 Replies

Transfer Files With Ftp With Ftpwebrequest?

May 26, 2010

currently I'm working on this ftp transfer. [URL]

I have setup my server computers iis to have a ftp site on port 21 and transfering files works great. But I want to add ftp to a hosted site I got on the server and it's here where I get the problems with connecting. when I try to connect through the command promt I get unknown host error. I have changed the port and open it up in firewall. and even if I could connect how can I decide what folder I want to upload to?

View 3 Replies

Forms Data Controls :: Uplaoding Filesize & Zipping It?

Mar 24, 2011

i am using upload control to upload files on server i am using VS2005 framework 2.0i have given a limit of 50 MB filesize for uplaodng .the file uploading takes place properly but1) the harddisk space problem. so how do i zip the file in code when the file is selected for uplaoding & when the user clicks view . it shld be unzipped & displayed to teh user2) i need to display a limit of 50 mbif the size is above 50 MB , the code shld dispaly a mesage & exitsubi need to use the code in the save click of a button3)if i need to uplaod a file of max 50 mb wht sgld be teh execution time out that needs to be specified in webconfig taking into consideration the system speed, the page shldnot blank out

View 6 Replies

Web Forms :: Data Getting Corrupted While Uploading Using FtpWebRequest?

Dec 25, 2010

I am using :

FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://www.contoso.com/test.htm");
request.Method = WebRequestMethods.Ftp.UploadFile;
// This example assumes the FTP site uses anonymous logon.
request.Credentials = new NetworkCredential ("anonymous","janeDoe@contoso.com");
// Copy the contents of the file to the request stream.
StreamReader sourceStream = new StreamReader("testfile.txt");
byte [] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
sourceStream.Close();
request.ContentLength = fileContents.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close();
FtpWebResponse response = (FtpWebResponse)request.GetResponse();

For uploading images and songs to the server. But the file is getting corrupted on upload. Normal upload is getting error due to security reason and access issues.

Had to dwell on to ftp. But in this case, file is getting corrupted.

View 1 Replies

Web Forms :: How To Set Port Number When Using FtpWebRequest For Uploading Files To FTP

Jun 16, 2015

[URL]

Unfortunately I get an error while uploading:

Invalid URI: Invalid port specified. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.UriFormatException: Invalid URI: Invalid port specified.

FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftp + ftpFolder + fileName);My FTP-address is:ftp://ftp.mydomain.dk:4001

View 1 Replies

FTPWebRequest - Looking For Code To Pull The File Contents From The Client Computer, Not The Server?

Sep 21, 2010

I have written the following code that successful ftps a file to the proper location as long as the file exists on the server itself....

However, I need the code to pull the file contents from the client computer, not the server.

Here is the code:

[Code]....

When I deploy this application to my staging server and test it, it's looking for the files on the staging server...not my local computer.

View 1 Replies

C# - Is Returning List<T> From Method Differ In Performance From Returning Collection<T>?

Jul 18, 2010

We have a web project that contain its business methods in a class library project called "Bll.dll"
some methods of Bll.dll return List<> ... from a source - that i don't remember now - told that returning Collection<> is better than returning List<> Is it a valid ? Note that i don't make any process on values returned from BLL methods .. just view it in a web page

View 5 Replies

Send Form Files To The Server Just To Get Summary Filesize Without Sending The Whole Files?

Dec 24, 2010

I have a form with 10 file inputs. They can contain 10 random files with random sizes. If I send these files to ASP.NET server with this code:

var count = HttpContext.Current.Request.Files.Count;
var TotalSize = 0;
for (int i = 0; i < count; i++ )
{
HttpPostedFile postedFile = HttpContext.Current.Request.Files.Get(i);
TotalSize += postedFile.ContentLength;
}

And as you can see I didn't save the files on the server, will this code just calculate the summary of files without need to receive the whole file from the client (And therefore it would be very fast)?

View 1 Replies

C# Text Box Is Only Returning The First Value?

Jan 10, 2011

I have a simple asp.net form that has a textbox that collects phonenumbers to send SMS messages. If I bypass the form and hardcode the numbers using the following format:

"2133211234",#1233211234"

the code works fine. However when i try to use this same format using my form, the sms will ONLY send to the first number. I have a feeling i'm missing out on some property on my form that will accept all of the values. how how i can add some lines of code that will allow users to enter numbers like this:

3123211234,4123212344 and have it converted to the format above when the number is submitted?

View 1 Replies

C# - Returning A File Using .net Mvc ?

Aug 12, 2010

I have a custom IHttpHandler which is used by thick clients to download files using a url such as

http://url.ashx?id=123&version=456

the code handler basically ends with context.Response.WriteFile(myLocalServerPath);

Is it possible to replace this using the typical asp.net mvc controller pattern ?

View 1 Replies

C# - Returning Custom Class From DAL?

Mar 25, 2011

I have an object with following attribute Books ---------- ID , Name

Now, I want to return an object for a gridview in presentation layer which has a lot more attributes then the original object

I don't have any business object composed of these attributes currently & I don't want to create it just for the sake of a gridview.

How do I create & return custom objects like these on the fly ? I am new to DTO's. Can someone give me an example to return a DTO inside my DAL ?

View 3 Replies

Returning Word Document From .net?

Mar 18, 2010

protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{

//string path = Server.MapPath("Help File editorial.doc");
string path = Server.MapPath("check.doc"); [code]...

What is wrong in the above code When i clk on imgbutton nothing happens. just page get refresed. I hv tried octet-stream as well as .doc

View 9 Replies

C# - Check For Session Before Returning?

Sep 8, 2010

I have a function inside a utility class which returns the current session User ID.
It throws object reference not set to instance of object ? How do I check it for null & remove this error ?

public static string GetSessionUserID
{
get
{
string userID = "";
if (System.Web.HttpContext.Current.Session["userID"].ToString() != null)
{
userID = System.Web.HttpContext.Current.Session["userID"].ToString();
}
if (userID == null)
{
throw new ApplicationException("UserID is null");
}
else
return userID;
}
}

View 2 Replies

C# - Wcf Returning A List From Wcf Sservice

Sep 19, 2010

How is it possible to return some kind of list from a WCF service, this the method in my WCF service.

My interface:

[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "Locations")]
IList<Location> GetLocations();
public IList<Location> GetLocations()
{
Pazar.Data.Repositories.LocationRepository locRepository =
new Pazar.Data.Repositories.LocationRepository();
return locRepository.GetRootLocations().ToList<Location>();
}
and this how my GetRootLocations looks like, It returns IQueryable, I wonder if I can maybe return IQueryable from my WCF service?
public IQueryable<Location> GetRootLocations()
{
IQueryable<Location> locations = GetAll().Where(p => !p.ID_Parent.HasValue).OrderBy(p => p.Sequence);
return locations;
}

View 3 Replies

Dataset Vs. Returning A Datatable

Aug 15, 2010

I have created alot of stored procedures in my application that return the result of a query in a datatable object. I never use a dataset. Why would I ever use a dataset over simply returning the result of a query as a datatable object?

View 3 Replies

C# - WCF Service Not Returning Value To JQuery

Mar 10, 2010

I have a problem with getting jquery to retrieve results from a WCF service. I am hosting the WCF service within IIS and when I attach the debugger to this process I can see that the code is processed successfully. However, when it hits the callback within jquery there is no data??

I have set up a trace on the wcf service and there are no errors. It just seems as though the data is lost after the wcf service method completes.

Here is the jquery code which calls the service:

$.get("http://ecopssvc:6970/ecopsService.svc/Echo", {echoThis: "please work"}, function(data) {
alert("Data Loaded: " + data);
});

Here is the wcf config:

<system.serviceModel>
<services>
<service name="EcopsWebServices.EcopsService" behaviorConfiguration="EcopsServiceBehaviours">
<endpoint address="" behaviorConfiguration="WebBehaviour"
binding="webHttpBinding" bindingConfiguration="" contract="EcopsWebServices.IEcopsServiceContract" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="WebBehaviour">
<webHttp />
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="EcopsServiceBehaviours">
<serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>

Here is the service contract:

[ServiceContract]
public interface IEcopsServiceContract
{
[WebGet]
[OperationContract]
string Echo(string echoThis);
}

Here is the Service implementation:

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class EcopsService : IEcopsServiceContract
{
#region IEcopsServiceContract Members
public string Echo(string echoThis)
{
return string.Format("You sent this '{0}'.", echoThis);
}
#endregion
}

View 3 Replies

MVC :: Javascript Not Returning Value To Controller

Jul 26, 2010

My js code is not returning my groupId back to the controller. Her is my js function:

[Code]....

I have checked for that the groupid comes in.

View 1 Replies

C# - SQL - Returning Duplicates From Join?

Dec 17, 2010

My SQL query joins on multiple tables, and because of this it is displaying multiple results. I know about SELECT DISTINCT, but one of the fields ('Account.Name') is occasionally different, so it treats this record as a new row. Here is my SQL:

[code]....

View 1 Replies

C# - Returning List From Mvc View

Mar 1, 2011

When I look in my DetailsReport(List<> filteredList) method its Count = 0. is it possible to send a List to your controller or is my code bad?

@Html.ActionLink("Print Results to Report",
"DetailsReport",
new {filteredList = Model} )

View 1 Replies

Function Not Returning True Value?

Jan 5, 2010

I have a call to a function in my business logic area. It should be returning a true.

[URL]

This url above is the culprit. The code doesn't seem to like the .asp type of file. I wonder why this is the case. I get a true response for a html or php type of file. The above returns false. Does anyone know why?

[Code]....

[Code]....

Public
Shared
Function MakeURL(ByVal url
As
String)
As
String
Return
"http://" & url.Replace("http://",
"")
End
Function

View 1 Replies

Returning Just Time (in Military) From DB In VB.NET

Mar 3, 2011

I'm saving military time into the database. Then I need to pull this data back out of the database. To get just the time without the date I can do this: String.Format("{0:T}", pullsaved.First.timeValue) But this returns a six digit time, e.g. 100000 (HHmmss). But I want it to return just HHmm (1000). I tried the following, but it didn't work. DateTime.ParseExact(String.Format("{0:T}", pullsaved.First.timeValue), "HHmm", CultureInfo.InvariantCulture)

View 2 Replies

Calling A Pop Up Page And Returning Value?

Jan 20, 2011

I need to call a popup page with terms and conditions (modal if possible), and once the user ticks the acceptance tick box in T&C popup and closes popup page I need to get the tick box value back into the calling page. How can achieve this via code?

View 6 Replies

AJAX :: ModalDialog And Returning A Value?

Jun 25, 2010

I am having an issue getting a value from a ModalDialog back to the page that called it so I can change the alternate text of an image based on what is entered in the textbox.Any thoughts on how to properly return the value and use it?Provided below is my code related to this.Main Page (This is a Content Page!) on PageLoad

[Code]....

This is the NoteForm.aspx's VB

[Code]....

NoteForm.aspx's Javascript/Source

[Code]....

[Code]....

View 2 Replies

Returning 401 Instead Of The Login Page?

Oct 4, 2010

I have an asp.net web application that use FormsAuthentication. Now, the application has a WCF Service that need to use Basic Authentication. So, I need to return the 401 status code, but everytime it's picked up by asp.net and redirecting me to the login page.How could I disable this feature and finally being able to throw a 401 without intervention from the FormsAuthentication module?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved