Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Tom Saddul
  Where is Tom Saddul?
 Paranaque
 Philippines
 Tom Saddul
 To: Cyril Baskir
  Where is Cyril Baskir?
 
 Australia
 Cyril Baskir
 Tags
Subject: RE: C# program: change date in settings file
Thread ID: 395805 Message ID: 395887 # Views: 38 # Ratings: 2
Version: Visual FoxPro 9 SP2 Category: General VFP Topics
Date: Tuesday, January 21, 2014 5:18:28 AM         
   


> I have an exe program written in C# (with source code). It stores some defaults (e.g. dates) in a settings file xrep.xst. I want to change the dates in this file using FoxPro.
>
> The author doesn't know FoxPro, but when I asked him how to do it he said:
>
> You can open file
XeroValueObject.cs

> You can define in your program as
XeroValueObject.cs
file.
>
> Does anyone know what this means in FoxPro?
>
> I opened the file he mentioned in notepad. This is what it contains (FromDate and ToDate are at the end):
>
>
>
using System;
> using System.Collections.Generic;
> using System.Linq;
> using System.Text;
> 
> namespace XeroApi.SystemOne
> {
>     [Serializable()]
>     public class XeroValueObject
>     {
>         public string UserAgent { get; private set; }
>         public string ConsumerKey { get; set; }
>         public string ConsumerSecret { get; set; }
>         public string OutputFolder { get; set; }
>         public string Delimeter { get; set; }
>         public DateTime FromDate { get; set; }
>         public DateTime ToDate { get; set; }
>     }
> }

>
>
>
>
> He has a settings button on his form, where I can change the dates. But I want to prefill the dates from VFP.
> Looking thru the code, this is where he saves the settings:
>
>
>
      private void SaveSettings(XeroValueObject xvo, string strFilename)
>         {
>             if (xvo == null) return;
>             try
>             {
>                 Stream s = File.Open(strFilename, FileMode.OpenOrCreate);
>                 BinaryFormatter b = new BinaryFormatter();
>                 b.Serialize(s, xvo);
>                 s.Close();
>                 MessageBox.Show("The Setting file has been saved successfully.", "Message");
>             }
>             catch (Exception)
>             {
>                 MessageBox.Show("Error in saving File.", "Error");
>             }
>         }
> 

>
>
> I dont know C#, but there are clever people here who do :)
>
> Can you give me some ideas as to how I can write my own dates to the settings file (or at least tell me what questions to ask)?
>
> BTW the settings file xrep.xst, when opened in notepad, is a binary file of some kind (I guess that's what the Serialize does).
> I can recognize some of the words in the file, but the dates are not in readable format.
>
>
> Cyril

You cannot define XeroValueObject.cs inside a VFP program because it is a CSharp source code which VFP cannot execute directly unless you use Rick Sthral's DotNetBridge where you can define the object inside CSharp language and access it there inside the .NET runtime. This is the easier path since the other programmer uses CSharp.NET which means the .NET runtime is already available in the PC which you can avail right away. However, this requires you an understanding of the C# language and the tools around it.

If you really want to do it in pure VFP code, you will have to hack through the binary file, detect the offset/location of the dates and convert the stored value to a VFP datetime. By using google or stackoverflow, you can see some codes on how to read/write directly from the stored datetime.

http://www.digisoftph.com/

ENTIRE THREAD

C# program: change date in settings file Posted by Cyril Baskir @ 1/20/2014 6:18:15 AM
RE: C# program: change date in settings file Posted by David Mustakim @ 1/20/2014 7:33:47 AM
RE: C# program: change date in settings file Posted by Stefan Wuebbe @ 1/20/2014 11:09:49 AM
RE: C# program: change date in settings file Posted by Pete Sass @ 1/20/2014 7:36:05 PM
RE: C# program: change date in settings file Posted by Cyril Baskir @ 1/20/2014 11:05:57 PM
RE: C# program: change date in settings file Posted by Tom Saddul @ 1/21/2014 5:18:28 AM