Если вам нужна такая функциональность, как папка сжатия любого обычного графического файлового менеджера, вы можете использовать следующий код, он использует модуль zipfile . Используя этот код, вы получите zip-файл с путем в качестве корневой папки.
import os
import zipfile
def zipdir(path, ziph):
# Iterate all the directories and files
for root, dirs, files in os.walk(path):
# Create a prefix variable with the folder structure inside the path folder.
# So if a file is at the path directory will be at the root directory of the zip file
# so the prefix will be empty. If the file belongs to a containing folder of path folder
# then the prefix will be that folder.
if root.replace(path,'') == '':
prefix = ''
else:
# Keep the folder structure after the path folder, append a '/' at the end
# and remome the first character, if it is a '/' in order to have a path like
# folder1/folder2/file.txt
prefix = root.replace(path, '') + '/'
if (prefix[0] == '/'):
prefix = prefix[1:]
for filename in files:
actual_file_path = root + '/' + filename
zipped_file_path = prefix + filename
zipf.write( actual_file_path, zipped_file_path)
zipf = zipfile.ZipFile('Python.zip', 'w', zipfile.ZIP_DEFLATED)
zipdir('/tmp/justtest/', zipf)
zipf.close()
Несмотря на то, что в настоящее время в WCF на Mono ведется работа (в основном, в отношении тех частей WCF, которые включены в Silverlight), стек WCF в основном не завершен. У меня сложилось впечатление, что функционируют только самые основные операции.
С другой стороны, обычные веб-службы должны быть полностью функциональными.