Dosya PHP akarsu -. PHP net kod bu C # çoğaltmak için nasıl?

0 Cevap

Ben biz yapılandırma dosyalarını yüklemek için gereken bir web hizmeti için bir arayüz yazıyorum. Dokümantasyon, sadece ben aşina değilim C #. Net bir örnek sağlar. PHP bu uygulamaya çalışıyorum.

Her iki dilde aşina birisi bana doğru yönde işaret edebilir? Ben bütün temellerini anlamaya, ama ben FileStream, readBytes ve UploadDataFile fonksiyonlar için uygun bir PHP yedek anlamaya çalışıyorum. Ben RecService nesne web hizmeti için URL'sini içeren inanıyoruz. Yardımlarınız için teşekkürler!

    private void UploadFiles() {
    clientAlias = “<yourClientAlias>”; 
    string filePath = “<pathToYourDataFiles>”; 
    string[] fileList = {"Config.txt", "ProductDetails.txt", "BrandNames.txt", "CategoryNames.txt", "ProductsSoldOut.txt", "Sales.txt"}; 
    RecommendClient RecService = new RecommendClient();
    for (int i = 0; i < fileList.Length; i++) {
        bool lastFile = (i == fileList.Length ‐ 1); //start generator after last file 
        try {
            string fileName = filePath + fileList[i]; 
            if (!File.Exists(fileName))
                continue;   // file not found
            }
            // set up a file stream and binary reader for the selected file and convert to byte array 
            FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fStream);
            byte[] data = br.ReadBytes((int)numBytes); br.Close();
            // pass byte array to the web service
            string result = RecService.UploadDataFile(clientAlias, fileList[i], data, lastFile); fStream.Close(); fStream.Dispose();
        } catch (Exception ex) {
            // log an error message
        }
    }
}

0 Cevap